Take a look at this;
`Setup the game
SYNC ON:SYNC RATE 0:AUTOCAM OFF:HIDE MOUSE
`Make a player object
MAKE OBJECT CUBE 1,10
POSITION OBJECT 1,500,0,0
`Make a matrix, its only for a visual aspect, and doesnt effect collision at all.
FOR x = 1 TO 10
FOR y = 1 TO 10
DOT x,y,RGB(000,RND(255),000)
NEXT y
NEXT x
GET IMAGE 1,1,1,10,10
MAKE MATRIX 1,1000,1000,10,10
PREPARE MATRIX TEXTURE 1,1,10,10
POSITION MATRIX 1,0,0,0
RANDOMIZE MATRIX 1,60
UPDATE MATRIX 1
`Setup the camera
POSITION CAMERA 500,200,-500
`Main loop
DO
`Handle object movement
MOVE OBJECT 1, (UPKEY()-DOWNKEY())*0.5
TURN OBJECT LEFT 1, (LEFTKEY()-RIGHTKEY())*0.5
`Store the object's current X and Z position.
x# = OBJECT POSITION X(1)
z# = OBJECT POSITION Z(1)
`Now we calculate the y position of object 1. We do this by using the GET GROUND HEIGHT() command.
`This command has 3 parameters; the first is the matrix number of the matrix you want to find the height of,
`the second/third is the x#/y# location in the world that you want to find the height of the tile located there.
`Basically, we provide the command with our player's x and z location, and it returns the y location the player
`should be at to be walking ontop of the matrix.
`Also, we add to this number half of the object's height. This way, the exact bottom of the player's cube will stay
`directly on the surface of the matrix, instead of the centre of the object being on the surface, which would look weird.
y# = (OBJECT SIZE Y(1)/2) + GET GROUND HEIGHT(1,x#,z#)
`Finally, position the object at it's newly calculated y location.
POSITION OBJECT 1, x#,y#,z#
`Refresh the screen
SYNC
`Repeat
LOOP