Try this:
cls rgb(255,0,0)
box 2,2,30,30
get image 1,0,0,32,32
sync on: sync rate 0
msize = 5000
msize2 = msize / 2
tiles = 10
tsize = msize/tiles
make matrix 1,msize,msize,tiles,tiles
prepare matrix texture 1,1,1,1
randomize matrix 1,150
`set matrix 1,1,1,1,1,1,1,1
position matrix 1,-msize2,0,-msize2
update matrix 1
position camera -250,80,-250
rotate camera 0,0,0
hide mouse
do
`simple camera rotation and movement with cursor keys
if upkey()then move camera 2
if downkey() then move camera -2
if rightkey() then yrotate camera wrapvalue(camera angle y()+1)
if leftkey() then yrotate camera wrapvalue(camera angle y()-1)
`this takes care of the matrix
ScrollMatrix(1,msize,tsize)
h#=get ground height(1,camera position x()-matrix position x(1),camera position z()-matrix position z(1))
position camera camera position x(),h#+100,camera position z()
sync
loop
function ScrollMatrix(mnum,msize,tsize)
cx = camera position x()
cz = camera position z()
mx = matrix position x(mnum)
mz = matrix position z(mnum)
dx=(mx+msize/2)-cx
dz=(mz+msize/2)-cz
if dz > tsize
shift matrix down mnum
position matrix mnum,mx,0,mz-tsize
endif
if dz < -tsize
shift matrix up mnum
position matrix mnum,mx,0,mz+tsize
endif
if dx > tsize
shift matrix right mnum
position matrix mnum,mx-tsize,0,mz
endif
if dx < -tsize
shift matrix left mnum
position matrix mnum,mx+tsize,0,mz
endif
update matrix mnum
endfunction
Note the get ground height function has deduct current matrix position to work properly.
Boo!