I haven't tested it from any position but here's the idea
rem Generic Matrix Template
rem Player = object 10
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
x#=2000.0:z#=500.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
gosub Setupland1
gosub makeplayer
gosub make_enemies
gosub resetcam
do
if inkey$()="e" then sync rate 0
if inkey$()="E" then sync rate 60
gosub printdata
gosub camera_controls
gosub update_camera
gosub Playercontrol
gosub scenerylife
gosub turntorso
SYNC
loop
scenerylife:
if object position x(100)>2600 then limit1=1
if object position x(100)<1400 then limit1=0
if limit1=0 then move object 100,1
if limit1=1 then move object 100,-1
return
turntorso:
rotangle#=atanfull((object position x(100)-x#),(object position z(100)-z#))
rotate limb 10,1,0.0,rotangle#-a#,0.0
return
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
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
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#+15,z#
yrotate object 10,a#
if upkey()=1 and s#<1.2 then s#=s#+0.2
if downkey()=1 and s#>-1.2 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
rem -------CAMERA--------
camera_controls:
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
mymousez=mousemovez()
if mymousez>0 then camdist=camdist+10
if mymousez<0 then camdist=camdist-10
return
update_camera:
position mouse 300,300
ca#=wrapvalue(a#+camrot)
cx#=newxvalue(x#,ca#,camdist)
cz#=newzvalue(z#,ca#,camdist)
cy#=h#
position camera cx#,cy#+camhgt,cz#
rem Point camera at object
point camera x#,h#+camhgt+campointh,z#
return
Resetcam:
set camera range 1,20000
camdist=-150
camhgt=80
camrot=0
campointh=0
return
printdata:
set cursor 0,0
print "Polys=",statistic(1)
print "FPS=",screen fps()
print "x#= ",x#
print "z#= ",z#
print "hieght= ",h#
print "player angle= ",a#
print "rotation angle= ",rotangle#
return
rem -------------Characters----------------
makeplayer:
make object box 10,20,30,10
color object 10,rgb(100,100,200)
make object box 11,20,30,10
make mesh from object 11,11
delete object 11
add limb 10,1,11
offset limb 10,1,0,30,0
return
make_enemies:
make object cube 100,60
position object 100,2000,30,1200
yrotate object 100,90
return
end