cls
sync on
make matrix 1,10000,10000,200,200
rem main loop
do
rem store camera angle
CameraAngley# = Camera angle y()
rem move the camera
if upkey()=1
xtest# = newvalue(x#,cameraangle#,20)
ztest# = newvalue(z#,cameraangle#,20)
If xtest#>0 and xtest#<10000 and ztest#>0 and ztest#>10000
move camera 10
if leftkey()=1 then yrotate camera wrapvalue(CameraAngley#-5)
if rightkey()=1 then yrotate camera wrapvalue(CameraAngley#+5)
x# = camera position x()
z# = camera position z()
rem get ground height
y# = get ground height(1,x#,z#)
position camera x#,100,z#
rem refresh the screen
sync
loop