Challenge: 
Winner?: 
Yes
Code Snippet: 
set display mode 1024,768,32
autocam off
color backdrop 0
hide light 0
make light 1
position light 1,50,50,100
set light range 1,200
hide mouse
set camera range 0.05,10000
randomize timer()
sync on

for x=50 to 199
ink rgb(y#,y#,y#),0
inc y#,1.2
line x,0,x,400
next x
for x=200 to 399
line x,0,x,400
next x
for x=400 to 549
ink rgb(y#,y#,y#),0
dec y#,1.2
line x,0,x,400
next x
gradient=check_free_image_number()
get image gradient,0,0,600,400,1

terraform()


plain1=check_free_object_number()
make object plain plain1,20,15
texture object plain1,gradient
position object plain1,0,0,10
set object light plain1,0
ghost object on plain1,1
lock object on plain1
plain3=check_free_object_number()
make object plain plain3,15,20
zrotate object plain3,90
texture object plain3,gradient
position object plain3,0,0,9.5
set object light plain3,0
ghost object on plain3,1
lock object on plain3

make camera 1
position camera 1,camera position x(0),camera position y(0),camera position z(0)
screen=check_free_image_number()
set camera to image 1,screen,512,512

plain2=check_free_object_number()
make object plain plain2,0.8,0.6
texture object plain2,screen
position object plain2,0,0,0.5
set object light plain2,0
set alpha mapping on plain2,50
lock object on plain2

ink rgb(255,255,255),0
cls
set camera view 0,screen height()/6.0,screen width(),screen height()*5/6.0
set camera fov 120
set camera fov 1,121
set camera range 1,0.05,10000

l=200
z#=10
peripheral=1
fov#=120
do
`transition
if spacekey()=1 and peripheral=1 then turnoff=1
if spacekey()=1 and peripheral=0 then turnon=1

if turnoff=1
move object plain1,0.2
`move object plain2,0.2
hide object plain2
move object plain3,0.2
dec z#,0.2
if l>99 then dec l
set light range 1,l
if fov#>89 then dec fov#,0.2
set camera fov fov#
if z#<=0 then turnoff=0:peripheral=0
endif

if turnon=1
move object plain1,-0.2
`move object plain2,-0.2
show object plain2
move object plain3,-0.2
inc z#,0.2
if l<201 then inc l
set light range 1,l
if fov#<119 then inc fov#,0.2
set camera fov fov#
if z#>=10 then turnon=0:peripheral=1
endif


move_camera(0.15,1.5)
position camera 1,camera position x(0),camera position y(0),camera position z(0)
yrotate camera 1,camera angle y(0)
move_water()

text 0,screen height()/6.0,"FPS: "+str$(screen fps())

sync
loop















function terraform
sync
text 0,0,"Generating terrain ....."
sync
create bitmap 1,screen width(),screen height()
set current bitmap 1
global matrixsize
matrixsize=100
fog on
fog color rgb(180,180,250)
fog distance matrixsize*0.6
global object_seed
object_seed=1000000
global image_seed
image_seed=1000000
global grassimage
create_grass()
global skyimage
create_sky()
global waterimage
global water
global water2
create_water_image()
create_water()
`set size of terrain
rows=60
columns=60

`create terrain
make matrix 1,matrixsize,matrixsize,columns,rows

`set mountain peaks
number_of_peaks=rnd(35)+10
max_height=15

dim peakx(number_of_peaks)
dim peakz(number_of_peaks)
dim height(number_of_peaks)
for peak=1 to number_of_peaks
  `set x,z coordinates for peak
  peakx(peak)=rnd(columns-10)+5
  peakz(peak)=rnd(rows-10)+5
  `set height of peak
  height(peak)=rnd(max_height)+10
  `create peak
  set matrix height 1,peakx(peak),peakz(peak),height(peak)
next peak

num=rows*columns
dim obnum(rows+1,columns+1)
dim v#(rows,columns)

`give each tile an x,z coordinate for use later
for x=1 to rows
for z=1 to columns
obnum(x,z)=ob
ob=ob+1
next z
next x

`texture matrix
prepare matrix texture 1,grassimage,rows,columns
tile=1
for x=rows-1 to 0 step -1
for z=0 to columns-1
set matrix tile 1,z,x,tile
inc tile
next z
next x


`adjust height of points between peaks
elasticity#=0.3
damping#=0

for time=1 to 100

for peak=1 to number_of_peaks
  set matrix height 1,peakx(peak),peakz(peak),height(peak)
next peak

for x=1+1 to rows-1
for z=1+1 to columns-1
if x<rows
distxp1#=get matrix height(1,x+1,z)-get matrix height (1,x,z)
endif
if x>1
distxm1#=get matrix height(1,x-1,z)-get matrix height (1,x,z)
endif
if z<columns
distzp1#=get matrix height(1,x,z+1)-get matrix height (1,x,z)
endif
if z>1
distzm1#=get matrix height(1,x,z-1)-get matrix height (1,x,z)
endif
vectorsum#=distxp1#+distxm1#+distzp1#+distzm1#
a#=vectorsum#*elasticity#
v#(obnum(x,z))=v#(obnum(x,z))+a#
set matrix height 1,x,z,get matrix height(1,x,z)+v#(obnum(x,z))
v#(obnum(x,z))=v#(obnum(x,z))*damping#
next z
next x
update matrix 1
next time

create_skysphere()
position camera 65,get ground height(1,65,65)+2,65
point camera 75,get ground height(1,75,75),75
set current bitmap 0
ink rgb(255,255,255),0

endfunction




function check_free_object_number

`this handy function means that you never have to worry about
`remembering object numbers.  You just give them names you can remember,
`and this function will find the next available number to assosciate
`with that name.  Just call the function by, for example, writing:
`
`ball=check_free_object_number
`make object sphere ball,1

object=object_seed
repeat
inc object
until object exist(object)=0

endfunction object

function check_free_image_number()

`this functionworks in the same way as the check_free_object function,
`except it works for images.

image=image_seed
repeat
inc image
until image exist(image)=0

endfunction image

function create_grass

`make a shaded box
box 0,0,100,100,rgb(100,150,100),rgb(50,200,20),rgb(80,0,10),rgb(150,200,0)

`and speckle it with random dots
for x=0 to 100
  for y=0 to 100
    if rnd(5)=0
      r=rnd(150)
      g=rnd(250)
      b=rnd(100)
      ink rgb(r,g,b),0
      dot x,y
    endif
  next x
next y


grassimage=check_free_image_number()
get image grassimage,0,0,100,100

endfunction

function create_skysphere

`get image for sphere by taking snapshot of terrain
image=check_free_image_number()
set camera fov 90
position camera matrixsize/2.0,3,-matrixsize*0.3
sync
get image image,0,0,screen width(),screen height()
set camera fov 60

`sphere 1 (mountains near) - just a sphere textured with the captured image
object=check_free_object_number()
make object sphere object,matrixsize*2
set object cull object,0
texture object object,image
set object texture object,2,1
scale object texture object,3,1
set object fog object,0
set object light object,0
set object transparency object,4
position object object,matrixsize/2,0,matrixsize/2

`sphere 2 (mountains far) - and another one further out. The inner sphere must be
`transparent, though, to see this one.
object=check_free_object_number()
make object sphere object,matrixsize*2.5
yrotate object object,30
set object cull object,0
texture object object,image
set object texture object,2,1
scale object texture object,3,1
set object fog object,0
`set object light object,0
set object transparency object,4
ghost object on object,4
set object emissive object,rgb(180,150,250)
fade object object,70
position object object,matrixsize/2,0,matrixsize/2

`sphere 3 (sky) - a third, outer sphere for the sky
object=check_free_object_number()
make object sphere object,matrixsize*4
set object cull object,0
texture object object,skyimage
scale object texture object,1,1.8
set object light object,0
set object fog object,0

endfunction

function create_sky()
`creates a dark to light bluish gradient
cls
for n=0 to 250
  ink rgb(n,n,250),0
  line 0,n,250,n
next n

skyimage=check_free_image_number()
get image skyimage,0,0,250,250

endfunction


function create_water_image

`creates a shaded box
box 0,0,100,100,rgb(150,150,200),rgb(50,200,200),rgb(80,0,200),rgb(150,100,200)

`and speckles with white bits
for x=0 to 100
  for y=0 to 100
    if rnd(5)=0
      r=(250)
      g=(250)
      b=(250)
      ink rgb(r,g,b),0
      dot x,y
    endif
  next x
next y


waterimage=check_free_image_number()
get image waterimage,0,0,100,100



endfunction


function create_water

`just a plane textured with the water image
water=check_free_object_number()
make object plain water,matrixsize*4,matrixsize*4
texture object water,waterimage
set object texture water,2,1
scale object texture water,4,4
xrotate object water,90
set object fog water,0
set object emissive water,rgb(220,220,200)
ghost object on water
set alpha mapping on water,20
water2=check_free_object_number()
make object plain water2,matrixsize*4,matrixsize*4
texture object water2,waterimage
xrotate object water2,90
position object water2,0,1,0
set object texture water2,2,1
scale object texture water2,4,4
set object light water2,0
set object fog water2,0

endfunction

function move_water

`moves the texture along a bit
scroll object texture water,0.001,0
scroll object texture water2,-0.001,0
`and moves the water up and down according to a sine wave
position object water,0,0.5*sin(theta#)+3,0
inc theta#,1

endfunction

function move_camera(movespeed#,turnspeed#)

control camera using arrowkeys 0,movespeed#,turnspeed#
position camera camera position x(),get ground height(1,camera position x(),camera position z())+0.2,camera position z()

endfunction