you could get some help from this one:
_______TOP_______:
rem Generic Template
rem Player = object 10
rem Cubes = objects 100-120
_____INITIALIZE_____:
set display mode 1024,768,32
SYNC ON
SYNC RATE 60
backdrop on
color backdrop rgb(10,100,100)
autocam off
set global collision off
global objnum
x#=1000.0:z#=1000.0:a#=0.0:s#=0.0:h#=0.0
cx#=0.0:cy#=0.0:cz#=0.0:ca#=0.0:camght=50
camrot=0:camdist=0:camlen=0:pdist#=0:collcheck#=0
collx#=0:collz#=0:objnum=0
gosub Setupland1
gosub makeplayer
gosub makeobjects
gosub ambient
gosub resetcam
_____DO_LOOP_____:
do
if x#<100 then x#=100
if z#<100 then z#=100
if x#>landsize-100 then x#=landsize-100
if z#>landsize-100 then z#=landsize-100
collx#=x#:collz#=z#
if inkey$()="e" then sync rate 0
if inkey$()="E" then sync rate 60
gosub printdata
gosub camera_control
gosub update_camera
gosub Playercontrol
gosub checkcollision
SYNC
loop
rem -------------ROUTINES--------------------
checkcollision:
if inkey$()="r" then return
for n=100 to 121
xdif#=object position x(n)-x#
zdif#=object position z(n)-z#
pdist#=sqrt(xdif#*xdif#+zdif#*zdif#)
if pdist#<200
if s#>0
a1#=wrapvalue(a#+40)
a2#=wrapvalue(a#-40)
to1x#=newxvalue(x#,a1#,80)
to1z#=newzvalue(z#,a1#,80)
to2x#=newxvalue(x#,a2#,80)
to2z#=newzvalue(z#,a2#,80)
collcheck1#=intersect object(n,x#,10,z#,to1x#,h#,to1z#)
collcheck2#=intersect object(n,x#,10,z#,to2x#,h#,to2z#)
if collcheck1#<16 and collcheck1#>0 then x#=collx#:z#=collz#:s#=0:objnum=n:return
if collcheck2#<16 and collcheck2#>0 then x#=collx#:z#=collz#:s#=0:objnum=n:return
endif
if s#<0
a1#=wrapvalue(a#+130)
a2#=wrapvalue(a#-130)
to1x#=newxvalue(x#,a1#,80)
to1z#=newzvalue(z#,a1#,80)
to2x#=newxvalue(x#,a2#,80)
to2z#=newzvalue(z#,a2#,80)
collcheck1#=intersect object(n,x#,10,z#,to1x#,h#,to1z#)
collcheck2#=intersect object(n,x#,10,z#,to2x#,h#,to2z#)
if collcheck1#<16 and collcheck1#>0 then x#=collx#:z#=collz#:s#=0:objnum=n:return
if collcheck2#<16 and collcheck2#>0 then x#=collx#:z#=collz#:s#=0:objnum=n:return
endif
endif
next n
return
____SET_SCENERY___:
Setupland1:
rem create ground 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
get image 2,0,0,250,250
landsize=4000:grid=30:mtxrandomize=1
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
update matrix 1
return
_____CONTROL_PLAYER___:
Playercontrol:
rem ---- Control Character ----
x#=newxvalue(x#,a#,s#)
z#=newzvalue(z#,a#,s#)
h#=get ground height(1,x#,z#)
position object 10,x#,h#+8,z#
yrotate object 10,a#
if upkey()=1 and s#<8 then s#=s#+0.1
if downkey()=1 and s#>-8 then s#=s#-0.2
if leftkey()=1 then a#=wrapvalue(a#-1)
if rightkey()=1 then a#=wrapvalue(a#+1)
if inkey$()="ù" then s#=0.0
if inkey$()="à" then s#=10.0
return
______CAMERA_ROUTINES____:
rem -------CAMERA--------
camera_control:
if mouseclick()=1
position mouse 300,300
mymousex=mousemovex()
if mymousex>0 then camrot=camrot+2
if mymousex<0 then camrot=camrot-2
mymousey=mousemovey()
if mymousey>0 then campointh=campointh+3
if mymousey<0 then campointh=campointh-3
endif
mymousez=mousemovez()
if mymousez>0 then camdist=camdist+10
if mymousez<0 then camdist=camdist-10
rem camera update
update_camera:
rem Position camera to the back of the character
ca#=wrapvalue(a#+camrot)
cx#=newxvalue(x#,ca#,camdist)
cz#=newzvalue(z#,ca#,camdist)
cy#=h#
position camera cx#,cy#+camhgt,cz#
point camera x#,h#+camhgt+campointh,z#
return
rem camera reset
Resetcam:
set camera range 1,20000
camdist=-150
camhgt=60
camrot=0
campointh=0
return
_____PRINT_ON__SCREEN___:
printdata:
set cursor 0,0
print "Polys=",statistic(1)
print "FPS=",screen fps()
print "player x#= ",x#
print "player h#= ",h#
print "player z#= ",z#
print "player angle a#= ",a#
print "speed s#= ",s#
print "last hit object= ",objnum
return
printdata2:
set cursor 0,0
print statistic(1)
print screen fps()
return
____MAKE_OBJECTS____:
makeplayer:
make object cube 10,20
return
makeobjects:
randomize 1
cubesize=100
for n=100 to 120
make object cube n,cubesize
set object n,1,1,1,1,1,1
color object n,rgb(rnd(150),rnd(150),rnd(150))
xpos=rnd(landsize):zpos=rnd(landsize)
position object n,xpos,cubesize/2,zpos
next n
make object plain 121,400,400
color object 121,rgb(20,20,160)
position object 121,1000,100,1500
xrotate object 121,300
return
rem ------------------ambient----------------
_______AMBIENT_______:
ambient:
set ambient light 70
set directional light 0,0.1,0.2,0.25
position light 0,0.0,2000.0,0.0
point light 0,4000,0,4000
fog on
fog color rgb(150,150,200)
fog distance 10000
return
end