A simple matrix following code that i made a long time ago

the cube goes shakey sometimes but as i said i made it ages ago and i can't be bothered to fix it. Here's the code.
make matrix 1,1000,1000,50,50
randomize matrix 1,50
update matrix 1
make object box 1,4,2,5
position object 1,50,0,50
for x=2 to 5
make object sphere x,3
next x
make mesh from object 2,2
make mesh from object 3,3
make mesh from object 4,4
make mesh from object 5,5
delete object 2
delete object 3
delete object 4
delete object 5
add limb 1,1,2
add limb 1,2,3
add limb 1,3,4
add limb 1,4,5
offset limb 1,1,0,0,-2.5
offset limb 1,2,-2,0,0
offset limb 1,3,2,0,0
offset limb 1,4,0,0,2.5
rollright#=0
rollleft#=0
pitchdown#=0
pitchup#=0
for x=1 to 4
hide limb 1,x
next x
do
fHeight#=get ground height(1,limb position x(1,4),limb position z(1,4))
bHeight#=get ground height(1,limb position x(1,1),limb position z(1,1))
rHeight#=get ground height(1,limb position x(1,3),limb position z(1,3))
lHeight#=get ground height(1,limb position x(1,2),limb position z(1,2))
height#=get ground height(1,object position x(1),object position z(1))
position camera 0,object position x(1),object position y(1)+20,object position z(1)-30
point camera 0,object position x(1),object position y(1),object position z(1)
if upkey()=1 then move object 1,1
if downkey()=1 then move object 1,-1
if rightkey()=1 then turn object right 1,3
if leftkey()=1 then turn object left 1,3
position object 1,object position x(1),height#,object position z(1)
if limb position y(1,2)<lHeight#
rollright#=0
roll object right 1,5
endif
if limb position y(1,2)>lHeight#
roll object left 1,rollright#
rollright#=rollright#+0.05
endif
if limb position y(1,1)<bHeight#
pitchup#=0
pitch object down 1,5
endif
if limb position y(1,1)>bHeight#
pitch object up 1,pitchup#
pitchup#=pitchup#+0.05
endif
if limb position y(1,4)<fHeight#
pitchdown#=0
pitch object up 1,5
endif
if limb position y(1,4)>fHeight#
pitch object down 1,pitchdown#
pitchdown#=pitchdown#+0.05
endif
if limb position y(1,3)<rHeight#
rollright#=0
roll object left 1,5
endif
if limb position y(1,3)>rHeight#
roll object right 1,rollright#
rollright#=rollright#+0.05
endif
loop
Brains are for idiots