i made this codesnippet of a ball sliding down a matrix, but it doesn't work yet so maybe you can look at it and see the general concept...if i figure it out then i'll tell you
make matrix 1,1000,1000,100,100
randomize matrix 1,10
position matrix 1,20,0,20
position camera 100,20,100
make object sphere 1,2
color object 1,rgb(255,0,0)
position object 1,50,20,50
gravity as float
posx as float
posy as float
posz as float
height as float
heightleft as float
heightright as float
heightup as float
heightdown as float
heightupleft as float
heightupright as float
heightdownleft as float
heightdownright as float
offset as float
global height
global heightleft
global heightright
do
move_sphere(1,2)
gosub move_camera
loop
Move_Camera:
`Move camera with player controls...
if upkey()=1 then move camera 0,3
if downkey()=1 then move camera 0,-3
inc ymove,mousemovex()
inc xmove,mousemovey()
yrotate camera 0,ymove
xrotate camera 0,xmove
return
function move_sphere(id,size)
gravity=.2
offset=size+1
posx=object position x(id)
posy=object position y(id)
posz=object position z(id)
height=get ground height(1,posx,posz)
heightleft=get ground height(1,posx-offset,posz)
heightright=get ground height(1,posx+offset,posz)
heightup=get ground height(1,posx,posz+offset)
heightdown=get ground height(1,posx,posz-offset)
heightupleft=get ground height(1,posx-offset,posz+offset)
heightupright=get ground height(1,posx+offset,posz+offset)
heightdownleft=get ground height(1,posx-offset,posz-offset)
heightdownright=get ground height(1,posx+offset,posz-offset)
if height<=heightleft
if height<=heightright
if height<=heightup
if height<=heightdown
if height<=heightupleft
if height<=heightupright
if height<=heightdownleft
if height<=heightdownright
if posy-height<gravity then posy=height
if posy-height>gravity then posy=posy-gravity
goto complete
endif
endif
endif
endif
endif
endif
endif
endif
if heightleft<=height
if heightleft<=heightright
if heightleft<=heightup
if heightleft<=heightdown
if heightleft<=heightupleft
if heightleft<=heightupright
if heightleft<=heightdownleft
if heightleft<=heightdownright
if posy-heightleft<gravity then posy=heightleft
if posy-heightleft>gravity then posy=posy-gravity
posx=posx-offset
goto complete
endif
endif
endif
endif
endif
endif
endif
endif
if heightright<=height
if heightright<=heightleft
if heightright<=heightup
if heightright<=heightdown
if heightright<=heightupleft
if heightright<=heightupright
if heightright<=heightdownleft
if heightright<=heightdownright
if posy-heightright<gravity then posy=heightright
if posy-heightright>gravity then posy=posy-gravity
posx=posx+offset
goto complete
endif
endif
endif
endif
endif
endif
endif
endif
if heightup<=heightleft
if heightup<=heightright
if heightup<=height
if heightup<=heightdown
if heightup<=heightupleft
if heightup<=heightupright
if heightup<=heightdownleft
if heightup<=heightdownright
if posy-heightup<gravity then posy=heightup
if posy-heightup>gravity then posy=posy-gravity
posz=posz+offset
goto complete
endif
endif
endif
endif
endif
endif
endif
endif
if heightdown<=heightleft
if heightdown<=heightright
if heightdown<=heightup
if heightdown<=height
if heightdown<=heightupleft
if heightdown<=heightupright
if heightdown<=heightdownleft
if heightdown<=heightdownright
if posy-heightdown<gravity then posy=heightdown
if posy-heightdown>gravity then posy=posy-gravity
posz=posz-offset
goto complete
endif
endif
endif
endif
endif
endif
endif
endif
if heightupleft<=heightleft
if heightupleft<=heightright
if heightupleft<=heightup
if heightupleft<=heightdown
if heightupleft<=height
if heightupleft<=heightupright
if heightupleft<=heightdownleft
if heightupleft<=heightdownright
if posy-heightupleft<gravity then posy=heightupleft
if posy-heightupleft>gravity then posy=posy-gravity
posx=posx-offset
posz=posz+offset
goto complete
endif
endif
endif
endif
endif
endif
endif
endif
if heightupright<=heightleft
if heightupright<=heightright
if heightupright<=heightup
if heightupright<=heightdown
if heightupright<=heightupleft
if heightupright<=height
if heightupright<=heightdownleft
if heightupright<=heightdownright
if posy-heightupright<gravity then posy=heightupright
if posy-heightupright>gravity then posy=posy-gravity
posx=posx+offset
posz=posz+offset
goto complete
endif
endif
endif
endif
endif
endif
endif
endif
if heightdownleft<=heightleft
if heightdownleft<=heightright
if heightdownleft<=heightup
if heightdownleft<=heightdown
if heightdownleft<=heightupleft
if heightdownleft<=heightupright
if heightdownleft<=height
if heightdownleft<=heightdownright
if posy-heightdownleft<gravity then posy=heightdownleft
if posy-heightdownleft>gravity then posy=posy-gravity
posx=posx-offset
posz=posz-offset
goto complete
endif
endif
endif
endif
endif
endif
endif
endif
if heightdownright<=heightleft
if heightdownright<=heightright
if heightdownright<=heightup
if heightdownright<=heightdown
if heightdownright<=heightupleft
if heightdownright<=heightupright
if heightdownright<=heightdownleft
if heightdownright<=height
if posy-heightdownright<gravity then posy=heightdownright
if posy-heightdownright>gravity then posy=posy-gravity
posx=posx+offset
posz=posz-offset
goto complete
endif
endif
endif
endif
endif
endif
endif
endif
complete:
position object id,posx,posy,posz
endfunction
remember this is NOT working (well it is in THEORY
)...
what i did is i got 8 points around the ball (and one point right where the ball is) and i check to see if any of them are the lowest, and if they are then i moved the ball down (gravity\nothing depending on the distance i had left to go) and repositioned its x and y coordinates accordingly...but for some reason it doesn't work
, sorry
Formerly known as "DarkWing Duck"