rem random matrix function
rem by latch
rem 7/2/2008
 
set display mode 800,600,32
sync on
sync rate 60
autocam off
randomize timer()
 
mat=1
tilex=50
tilez=50
matx#=10000
matz#=10000
make matrix mat,matx#,matz#,tilex,tilez
randomize_matrix(mat,tilex,tilez,200)
 
do
   gosub _move_camera
   sync
loop
 
end
 
_move_camera:
   move camera (upkey()-downkey())*2
   turn camera right (rightkey()-leftkey())*2
   ht#=get ground height(mat,camera position x(),camera position z())
   position camera camera position x(),ht#+25,camera position z()
return
 
function randomize_matrix(mat,tilex,tilez,maxht)
   for z=0 to tilez
      for x=0 to tilex
         pcnt#=(rnd(99)+1)/100.0
         y#=(rnd(maxht))*pcnt#
         set matrix height mat,x,z,y#
      next x
   next z
 
   update matrix mat
endfunction