I just posted this somewhere else but it might help you:
rem Make a texture for the matrix
cls
ink rgb(200,0,0),0
box 0,0,31,31
ink rgb(0,200,0),0
box 32,0,63,31
ink rgb(0,0,200),0
box 0,32,31,63
ink rgb(255,200,0),0
box 32,32,63,63
get image 1,0,0,63,63
rem Make a matrix
make matrix 1,1000,1000,50,50
prepare matrix texture 1,1,2,2
randomize matrix 1,50
for x=0 to 49
for z=0 to 49
Tile=rnd(4)
if Tile<1 then Tile=1
if Tile>4 then Tile=4
set matrix tile 1,x,z,Tile
next z
next x
update matrix 1
rem Make a player object
make object box 1,20,20,20
make object box 2,20,20,20
scale object 2,-105,-105,-105
make mesh from object 2,2
delete object 2
add limb 1,1,2
color limb 1,0,rgb(200,0,200)
color limb 1,1,rgb(0,0,0)
rem Make walls
make object box 2,1000,100,20
make object box 3,1000,100,20
scale object 3,-105,-105,-101
make mesh from object 3,3
delete object 3
add limb 2,1,3
color limb 2,0,rgb(255,255,255)
color limb 2,1,rgb(0,0,0)
position object 2,500,35,990
make object box 3,1000,100,20
make object box 4,1000,100,20
scale object 4,-105,-105,-101
make mesh from object 4,4
delete object 4
add limb 3,1,4
color limb 3,0,rgb(255,255,255)
color limb 3,1,rgb(0,0,0)
position object 3,500,35,10
make object box 4,20,100,1000
make object box 5,20,100,1000
scale object 5,-101,-105,-105
make mesh from object 5,5
delete object 5
add limb 4,1,5
color limb 4,0,rgb(255,255,255)
color limb 4,1,rgb(0,0,0)
position object 4,10,35,500
make object box 5,20,100,1000
make object box 6,20,100,1000
scale object 6,-101,-105,-105
make mesh from object 6,6
delete object 6
add limb 5,1,6
color limb 5,0,rgb(255,255,255)
color limb 5,1,rgb(0,0,0)
position object 5,990,35,500
rem Start player variables
x#=500
y#=0
z#=500
ang#=0
rem Setup manual synchronisation
sync on
sync rate 0
rem Start main loop
do
rem Control player
if upkey()=1
x#=newxvalue(x#,ang#,1)
z#=newzvalue(z#,ang#,1)
endif
if downkey()=1
x#=newxvalue(x#,ang#,-1)
z#=newzvalue(z#,ang#,-1)
endif
if x#<30 then x#=30
if x#>970 then x#=970
if z#<30 then z#=30
if z#>970 then z#=970
if rightkey()=1
ang#=wrapvalue(ang#+1)
endif
if leftkey()=1
ang#=wrapvalue(ang#-1)
endif
y#=get ground height(1,x#,z#)+10
position object 1,x#,y#,z#
yrotate object 1,ang#
rem Control camera
set camera to follow x#,y#,z#,ang#,100,100,3.5,0
point camera x#,y#,z#
rem Update screen
sync
rem End the main loop
loop