rem Texture Matrix Grid
rem Player = object 10
set display mode 1920,1080,32
SYNC ON
SYNC RATE 60
backdrop on
color backdrop rgb(10,100,100)
autocam off
set global collision off
x#=0.0:z#=0.0:a#=0.0:s#=0.0:h#=0.0
cx#=0.0:cy#=0.0:cz#=0.0:ca#=0.0:camght=0
camrot=0:camdist=0
gosub loadimages
gosub makematrix
gosub makeplayer
gosub reset
do
if inkey$()="r" then gosub reset
if inkey$()="t" and textureflag=1 then gosub retexturematrix:textureflag=2:wait 100
if inkey$()="t" and textureflag=2 then gosub retexturematrix:textureflag=1:wait 100
gosub printdata
gosub camera_controls
gosub update_camera
gosub Playercontrol
SYNC
loop
rem -------------ROUTINES--------------------
rem matrixes images
loadimages:
load image "matrixtex3.bmp",1
load image "matrixtiles.bmp",2
return
makematrix:
landsize=4000:grid=4:mtxrandomize=1
make matrix 1,landsize,landsize,grid,grid
set matrix 1,1,0,0,1,1,1,1
prepare matrix texture 1,2,grid,grid
count=1
for n=grid-1 to 0 step -1
for m=0 to grid-1
set matrix tile 1,m,n,count
count=count+1
next m
next n
randomize matrix 1,mtxrandomize
update matrix 1
textureflag=1
return
retexturematrix:
if textureflag=1
prepare matrix texture 1,1,grid,grid
endif
if textureflag=2
prepare matrix texture 1,2,grid,grid
endif
count=1
for n=grid-1 to 0 step -1
for m=0 to grid-1
set matrix tile 1,m,n,count
count=count+1
next m
next n
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#+40,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:
if mouseclick()=1
mymousex=mousemovex()
if mymousex>0 then cay#=wrapvalue(cay#+1.0)
if mymousex<0 then cay#=wrapvalue(cay#-1.0)
yrotate camera cay#
endif
mymousey=mousemovey()
if mymousey>0 then cax#=wrapvalue(cax#+0.5)
if mymousey<0 then cax#=wrapvalue(cax#-0.5)
xrotate camera cax#
mymousez=mousemovez()
if mymousez>0 then camdist=camdist+50
if mymousez<0 then camdist=camdist-50
return
rem camera update
update_camera:
position mouse 300,300
rem Position camera to the back of the character
cx#=newxvalue(x#,cay#,camdist)
cz#=newzvalue(z#,cay#,camdist)
cy#=h#
position camera cx#,cy#+camhgt,cz#
return
rem camera reset
Reset:
x#=landsize/2:z#=100
a#=0.0:s#=0.0
yrotate object 10,a#
set camera range 1,20000
camfollow=1
camdist=-200
camhgt=3000
camrot=0
cax#=65.0
xrotate camera cax#
cay#=0.0
yrotate camera cay#
return
printdata:
set cursor 0,0
print " Polys=",statistic(1)
print " FPS=",screen fps()
print " x#= ",x#
print " z#= ",z#
print " angle#= ",a#
print " speed#= ",s#
print
print " Press r to reset start position"
print " Press t to change matrix texture"
return
rem -------------Characters----------------
makeplayer:
make object cone 10,30
scale object 10,100,200,100
set object 10,1,1,0
xrotate object 10,90
fix object pivot 10
return
end