No, I did not forget that. And I typed the array as I should. Here is the entire source if it would help:
sync on : sync rate 70
set display mode 1024,768,32
set window on : set window title "This is a testing program"
rem Define user defined types
type pos
height as integer
newX as integer
newZ as integer
minX as integer
maxX as integer
minZ as integer
maxZ as integer
minXnegZ as integer
maxXnegZ as integer
minZnegX as integer
maxZnegX as integer
minXposZ as integer
maxXposZ as integer
minZposX as integer
maxZposX as integer
endtype
type remn
aFX as integer
aFZ as integer
aFXnegZ as integer
aFZnegX as integer
aFXposZ as integer
aFZposX as integer
aSXZ as integer
aSXZneg as integer
aSXZpos as integer
Alt as integer
finalHeight as integer
endtype
rem Global variables
global mouse_x as integer
global mouse_y as integer
global dist as integer
rem Create the enviroment enviroment
ConstructMatrixWithTexture(1,10000,10000,100,100,1,1,rgb(45,222,123),rgb(145,22,23),rgb(245,22,112),rgb(145,122,13),0)
for n=1 to 500
make object box n+1,40+rnd(100),44,40+rnd(100)
pos_x=rnd(9998)+1 : pos_z=rnd(9998)+1
position object n+1,pos_x,get ground height(1,pos_x,pos_z)+22,pos_z
next n
rem Create the palyer
make object sphere 1,7.5
color object 1,rgb(255,0,0)
position object 1,5000,0,5000
set object collision to spheres 1
set camera range 1,5000
dist = 400
rem Main loop
do
rem The text
text 1,1,"Screen fps: "+str$(screen fps())
text 1,3+text height("I"),"Object pos x: "+str$(object position x(1))
text 1,5+text height("I")*2,"Object pos z: "+str$(object position z(1))
text 1,7+text height("I")*3,"Object tile x: "+str$(int(object position x(1)/100))
text 1,9+text height("I")*4,"Object tile z: "+str$(int(object position z(1)/100))
text 1,11+text height("I")*5,"Tile height: "+str$(get ground height(1,object position x(1),object position z(1)))
rem Controls
position camera object position x(1)+mouse_x,object position y(1)+dist,object position z(1)+150+mouse_y
point camera object position x(1),object position y(1),object position z(1)
if mouseclick()=2 then inc mouse_x,mousemovex()*3 : inc mouse_y,mousemovey()*3
if mouseclick()=1 then inc dist,mousemovey()*2
if keystate(14)=1 then mouse_x = 0 : mouse_y = 0 : dist = 500
Movement()
rem Set the height of the matrix
if keystate(74)=1 then IncGroundHeight(1,object position x(1),object position z(1),100,100,-2)
if keystate(78)=1 then IncGroundHeight(1,object position x(1),object position z(1),100,100,2)
ApplyBasicEnviromentalSliding(1,0,0,10000,10000,2,501)
rem Update object positions
for n=1 to 500
position object n+1,object position x(n+1),get ground height(1,object position x(n+1),object position z(n+1))+22,object position z(n+1)
next n
rem Update screen
sync
loop
end
function Movement()
posz = object position z(1)-upkey()*6+downkey()*6
posx = object position x(1)+leftkey()*6-rightkey()*6
if posx <= 1 then posx = 1
if posx >= 9999 then posx = 9999
if posz <= 1 then posz = 1
if posz >= 9999 then posz = 9999
position object 1,posx,get ground height(1,object position x(1),object position z(1))+10,posz
endfunction
function IncGroundHeight(matrixNum,x as float,z as float,tileX as integer,tileZ as integer,height as float)
set matrix height matrixNum,x/tileX,z/tileZ,get matrix height(matrixNum,x/tileX,z/tileZ)+height
update matrix matrixNum
endfunction
function ConstructMatrixWithTexture(matrixNum as integer,sizeX as integer,sizeZ as integer,tilesX as integer,tilesZ as integer,across as integer,down as integer,color1 as integer,color2 as integer,color3 as integer,color4 as integer, memoryView as boolean)
image as integer
box 100,100,200,200,color1,color2,color3,color4
repeat : inc image,1 : until image exist(image)=0
get image 1,100,100,200,200
cls
make matrix matrixNum,sizeX,sizeZ,tilesX,tilesZ
prepare matrix texture matrixNum,1,across,down
if memoryView = 1 then delete image image
endfunction
function ApplyBasicEnviromentalSliding(matrixNum as integer,matrixStartX as integer,matrixStartZ as integer,matrixWidthX as integer,matrixWidthZ as integer,startObj as integer,endObj as integer)
if endObj-startObj >= 0
rem Create the local arrays
dim positions( endObj-startObj ) as pos
dim remnants( endObj-startObj ) as remn
rem The FOR-NEXT loop
for n=startObj to endObj
rem The different positions and their height
positions(n).height = get ground height(matrixNum,object position x(n),object position z(n))
positions(n).minX = get ground height(matrixNum,object position x(n)-1,object position z(n))
positions(n).maxX = get ground height(matrixNum,object position x(n)+1,object position z(n))
positions(n).minZ = get ground height(matrixNum,object position x(n),object position z(n)-1)
positions(n).maxZ = get ground height(matrixNum,object position x(n),object position z(n)+1)
positions(n).minXnegZ = get ground height(matrixNum,object position x(n)-1,object position z(n)-1)
positions(n).maxXnegZ = get ground height(matrixNum,object position x(n)+1,object position z(n)-1)
positions(n).minZnegX = get ground height(matrixNum,object position x(n)-1,object position z(n)-1)
positions(n).maxZnegX = get ground height(matrixNum,object position x(n)-1,object position z(n)+1)
positions(n).minXposZ = get ground height(matrixNum,object position x(n)-1,object position z(n)+1)
positions(n).maxXposZ = get ground height(matrixNum,object position x(n)+1,object position z(n)+1)
positions(n).minZposX = get ground height(matrixNum,object position x(n)+1,object position z(n)-1)
positions(n).maxZposX = get ground height(matrixNum,object position x(n)+1,object position z(n)+1)
rem Compare the heights and find the lowest point around the object
if positions(n).minX < positions(n).maxX
remnants(n).aFX = positions(n).minX
else
remnants(n).aFX = positions(n).minZ
endif
if positions(n).minZ < positions(n).maxZ
remnants(n).aFZ = positions(n).maxX
else
remnants(n).aFZ = positions(n).maxZ
endif
if remnants(n).aFX < remnants(n).aFZ
remnants(n).aSXZ = remnants(n).aFX
else
remnants(n).aSXZ = remnants(n).aFZ
endif
if positions(n).minXnegZ < positions(n).maxXnegZ
remnants(n).aFXnegZ = positions(n).minXnegZ
else
remnants(n).aFXnegZ = positions(n).minZnegX
endif
if positions(n).minZnegX < positions(n).maxZnegX
remnants(n).aFZnegX = positions(n).minZnegX
else
remnants(n).aFZnegX = positions(n).minZnegX
endif
if remnants(n).aFXnegZ < remnants(n).aFZnegX
remnants(n).aSXZneg = remnants(n).aFXnegZ
else
remnants(n).aSXZneg = remnants(n).aFZnegX
endif
if positions(n).minXposZ < positions(n).maxXposZ
remnants(n).aFXposZ = 1
else
remnants(n).aFXposZ = 0
endif
if positions(n).minZposX < positions(n).maxZposX
remnants(n).aFZposX = 1
else
remnants(n).aFZposX = 0
endif
if remnants(n).aFXposZ < remnants(n).aFZposX
remnants(n).aSXZpos = remnants(n).aFXposZ
else
remnants(n).aSXZpos = remnants(n).aFZposX
endif
if remnants(n).aSXZneg < remnants(n).aSXZpos
remnants(n).Alt = aSXZneg
else
remnants(n).Alt = aSXZpos
endif
if remnants(n).aSXZ < remnants(n).Alt
remnants(n).finalHeight = remnants(n).aSXZ
else
remnants(n).finalHeight = remnants(n).Alt
endif
rem Position the object in the lowest point
if remnants(n).finalHeight < positions(n).height
if remnants(n).finalHeight = positions(n).minX then positions(n).newX = object position x(n)-1 : positions(n).newZ = object position z(n)
if remnants(n).finalHeight = positions(n).maxX then positions(n).newX = object position x(n)+1 : positions(n).newZ = object position z(n)
if remnants(n).finalHeight = positions(n).minZ then positions(n).newX = object position x(n) : positions(n).newZ = object position z(n)-1
if remnants(n).finalHeight = positions(n).maxZ then positions(n).newX = object position x(n) : positions(n).newZ = object position z(n)+1
if remnants(n).finalHeight = positions(n).minXnegZ then positions(n).newX = object position x(n)-1 : positions(n).newZ = object position z(n)-1
if remnants(n).finalHeight = positions(n).maxXnegZ then positions(n).newX = object position x(n)+1 : positions(n).newZ = object position z(n)-1
if remnants(n).finalHeight = positions(n).minZnegX then positions(n).newX = object position x(n)-1 : positions(n).newZ = object position z(n)-1
if remnants(n).finalHeight = positions(n).maxZnegX then positions(n).newX = object position x(n)-1 : positions(n).newZ = object position z(n)+1
if remnants(n).finalHeight = positions(n).minXposZ then positions(n).newX = object position x(n)-1 : positions(n).newZ = object position z(n)+1
if remnants(n).finalHeight = positions(n).maxXposZ then positions(n).newX = object position x(n)+1 : positions(n).newZ = object position z(n)+1
if remnants(n).finalHeight = positions(n).minZposX then positions(n).newX = object position x(n)+1 : positions(n).newZ = object position z(n)-1
if remnants(n).finalHeight = positions(n).maxZposX then positions(n).newX = object position x(n)+1 : positions(n).newZ = object position z(n)+1
position object n,positions(n).newX,remnants(n).finalHeight + 22,positions(n).newZ
endif
next n
rem Undim the arrays
undim positions()
undim remnants()
rem Set up the limits of movement
if object position x(n) < matrixStartX then position object n,matrixStartX,object position y(n),object position z(n)
if object position x(n) > matrixStartX + matrixWidthX then position object n,matrixStartX + matrixWidthX,object position y(n),object position z(n)
if object position z(n) < matrixStartZ then position object n,object position x(n),object position y(n),matrixStartZ
if object position z(n) > matrixStartZ + matrixWidthZ then position object n,object position x(n),object position y(n),matrixStartZ + matrixWidthZ
endif
endfunction