note a lot is straight from the monster hunt tutorial
sync on
sync rate 0
autocam off
hide mouse
backdrop on
set camera range 1, 4000
backdrop on
color backdrop rgb(0, 14, 28)
fog on
fog distance 3000
fog color rgb(0, 14, 28)
rem matrix
load image "tgrass.bmp", 1
make matrix 1, 10000, 10000, 20, 20
prepare matrix texture 1, 1, 1, 1
fill matrix 1, 0, 1
randomize matrix 1, 120
rem Load
load image "twood.bmp", 2
load image "trock.bmp", 4
load object "bunker.3ds", 3
position object 3, 5000, get ground height(1, 5000, 5000), 5000
make object box 5, 8000, 3000, 1000
position object 5, 5000, 1500, 500
make object box 6, 8000, 3000, 1000
position object 6, 5000, 1500, 9500
make object box 7, 1000, 3000, 8000
position object 7, 500, 1500, 5000
make object box 8, 1000, 3000, 8000
position object 8, 9500, 1500, 5000
texture object 5, 4
texture object 6, 4
texture object 7, 4
texture object 8, 4
x# = 5000
z# = 5000
mainloop:
do
set cursor 0, 0
print screen fps()
set cursor 0, 30
print "x#"; x#
set cursor 0, 50
print "z#"; z#
set cursor 0, 70
print "y#"; y#
rem camera and movement input
oldcay# = cay#
oldcax# = cax#
cay# = wrapvalue(cay#+mousemovex()*0.5)
cax# = wrapvalue(cax#+mousemovey()*0.5)
caz# = camera angle z()
if upkey() = 1
xtest# = newxvalue(x#, cay#, 5)
ztest# = newzvalue(z#, cay#, 5)
if xtest# > 0 and xtest# < 10000 and ztest# > 0 and ztest# < 10000
x# = xtest#
z# = ztest#
endif
endif
if downkey() = 1
xtest# = newxvalue(x#, wrapvalue(cay#-180), 3)
ztest# = newzvalue(z#, wrapvalue(cay#-180), 3)
if xtest# > 0 and xtest# < 10000 and ztest# > 0 and ztest# < 10000
x# = xtest#
z# = ztest#
endif
endif
if leftkey() = 1
xtest# = newxvalue(x#, wrapvalue(cay#-90), 3)
ztest# = newzvalue(z#, wrapvalue(cay#-90), 3)
if xtest# > 0 and xtest# < 10000 and ztest# > 0 and ztest# < 10000
x# = xtest#
z# = ztest#
endif
endif
if rightkey() = 1
xtest# = newxvalue(x#, wrapvalue(cay#+90), 3)
ztest# = newzvalue(z#, wrapvalue(cay#+90), 3)
if xtest# > 0 and xtest# < 10000 and ztest# > 0 and ztest# < 10000
x# = xtest#
z# = ztest#
endif
endif
Rem Rotate camera
cTestX#=WrapValue(cAX#-180)
if cTestX# > 225 then cAX#=45
if cTestX# < 135 then cAX#=315
YRotate camera CurveAngle(cAY#,oldcAY#,24)
XRotate camera CurveAngle(cAX#,oldcAX#,24)
Y# = Get ground height(1,X#,Z#)+35
rem position camera and listener
if x# > 9000 then x# = 9000
if z# > 9000 then z# = 9000
if x# < 1000 then x# = 1000
if z# < 1000 then z# = 1000
position camera x#+30, y#, z#+30
position listener x#, y#, z#
rotate listener 0, cay#, 0
sync
loop