using the get ground height(MatrixNo,x,z) command gets the height of the matrix. If you use this command to get the height and check to see how high your object is then you can make a simple collision system. the code would look a bit like this:
`declare the collision function
function CheckMatrixCollision(MatrixNo,ObjectNo)
`get the matrix height, the object position and the object height offset
MatrixHeight=get ground height(MatrixNo,object position x(ObjectNo),object position z(ObjectNo))
ObjectPosition=Object Position y(ObjectNo)
ObjectHeightOffset=object size y(ObjectNo)
`check to see if they collide
if ObjectPosition<>MatrixHeight+ObjectHeightOffset then position object ObjectNo,object position x(ObjectNo),MatrixHeight+ObjectHeightOffset,object position z(ObjectNo)
`end function
endfunction
you would then have to implement this into your code something like this:
`set up the computer
sync on:sync rate 120
hide mouse:autocam off
`make a texture for the matrix
create bitmap 1,64,64
ink rgb(0,0,0),rgb(0,0,0)
box 0,0,64,64
ink rgb(255,0,255),rgb(0,0,0)
ellipse rnd(64),rnd(64),10,10
ink rgb(0,255,0),rgb(0,0,0)
ellipse rnd(64),rnd(64),5,5
ink rgb(0,0,255),rgb(0,0,0)
ellipse rnd(64),rnd(64),15,15
ink rgb(255,0,0),rgb(0,0,0)
ellipse rnd(64),rnd(64),20,20
get image 1,0,0,64,64,0
delete bitmap 1
`make and prepare the matrix
make matrix 1,10000,10000,100,100
randomize matrix 1,50
prepare matrix texture 1,1,2,2
for x=0 to 96 step 4
for y=0 to 99
set matrix tile 1,x,y,rnd(3)+1
set matrix tile 1,x+1,y,rnd(3)+1
set matrix tile 1,x+2,y,rnd(3)+1
set matrix tile 1,x+3,y,rnd(3)+1
next y
next x
update matrix 1
`make the object
make object cube 1,10
`begin loop
do
`control "player"
if upkey()=1 then move object 1,1
if downkey()=1 then move object 1,-1
if rightkey()=1 then yrotate object 1,object angle y(1)+1
if leftkey()=1 then yrotate object 1,object angle y(1)-1
`use the functions
CheckMatrixCollision(1,1)
CameraPosition(1)
`end the loop
sync
loop
`declare the collision function
function CheckMatrixCollision(MatrixNo,ObjectNo)
`get the matrix height, the object position and the object height offset
MatrixHeight=get ground height(MatrixNo,object position x(ObjectNo),object position z(ObjectNo))
ObjectPosition=Object Position y(ObjectNo)
ObjectHeightOffset=object size y(ObjectNo)
`check to see if they collide
if ObjectPosition<>MatrixHeight+ObjectHeightOffset then position object ObjectNo,object position x(ObjectNo),MatrixHeight+ObjectHeightOffset,object position z(ObjectNo)
`end function
endfunction
`declare the Camera function
function CameraPosition(ObjectNo)
`get player object position and store in X# and Z#
X# = Object position x(ObjectNo)
Z# = Object position z(ObjectNo)
`get new camera position and store in cZ# and cX#
cZ# = Newzvalue(Z#,aY#-180,100)
cX# = Newxvalue(X#,aY#-180,100)
`position camera
Position Camera cX#,100,cZ#
`point the camera at the player object
Point camera X#,50,Z#
`end function
endfunction
hope this helps