I changed the code just a little to make it so you can continue to float off the ground if it drops down, rather than staying the same height from the ground. I'm not sure which of the two you were going for.
The code now uses cy# for the camera's height (since that's what it is now instead of the distance you are floating from the ground). Also the new minground# value that I added is the minimum distance that the camera must stay from the ground. Also, I indented some stuff to make it a little easier to read.
rem Generic Matrix Template
SYNC ON
SYNC RATE 60
backdrop on
color backdrop rgb(10,100,100)
autocam off
set global collision off
set camera range 1,20000
cx#=1000.0: cy# = 100: cz#=1000.0:a#=0.0:s#=0.0:h#=0.0:minground# = 10
gosub Setupland1
position camera cx#,cy#,cz#
do
if inkey$()="e" then sync rate 0
if inkey$()="E" then sync rate 60
gosub printdata
gosub Playercontrol
SYNC
loop
rem -------------ROUTINES--------------------
Setupland1:
rem ground textures
rem create texture
cls rgb(0,100,20)
inkcolor#=rgb(255,255,255)
line 0,0,0,250
line 1,1,1,250
line 2,2,2,250
line 0,0,250,0
line 1,1,250,1
line 2,2,250,2
line 0,0,250,250
line 0,250,250,0
rem next n
get image 2,0,0,250,250
rem Make landscape
landsize=8000:grid=30:mtxrandomize=100
make matrix 1,landsize,landsize,grid,grid
set matrix 1,1,0,0,1,1,1,1
prepare matrix texture 1,2,1,1
randomize matrix 1,mtxrandomize
rem ***********
rem get ground done
update matrix 1
return
Playercontrol:
rem ---- Control Character ----
if inkey$()="w" and s#<3 then s#=s#+0.02
if inkey$()="s" and s#>-3 then s#=s#-0.02
if inkey$()="a" then a#=wrapvalue(a#-1)
if inkey$()="d" then a#=wrapvalue(a#+1)
if upkey()=1 then cy# = cy# + 2
if downkey()=1 then cy# = cy# - 2
cx#=newxvalue(cx#,a#,s#)
cz#=newzvalue(cz#,a#,s#)
`**********************************
h#=get ground height(1,cx#,cz#) + minground#
if cy# < h# then cy# = h#
`**********************************
position camera cx#,cy#,cz#
yrotate camera a#
return
printdata:
set cursor 0,0
print "Polys=",statistic(1)
print "FPS=",screen fps()
print "x#= ",x#
print "h#= ",h#
print "z#= ",z#
print "a#= ",a#
print "s#= ",s#
print "keys: w a s d and up down arrows "
return
end
Oh, and I bumped up the max speed value. Yay speed.
Anarchy Burger - hold the Government!