First, store the position of the object before it has moved. Then, after you have moved the object however you want (controlled by player or by computer, applied physics, etc), it is a simple matter of subtracting the old position you stored from the new position of the object to get the difference it has moved.
` Screen settings
sync on : sync rate 40 : autocam off : hide mouse
` Main object
make object sphere 1, 10 : position object 1, -45, 100, 0
` Ground box
make object box 2, 100, 20, 20
` Camera position
position camera 0, 50, -150 : point camera 0, 0, 0
` Main loop
do
` Record ball's old position (before movement)
oldX# = object position x(1) : oldY# = object position y(1)
` If ball is on ground, move left, otherwise, make ball fall
if object collision(1, 2) = 1
position object 1, object position x(1)+1, object position y(1), object position z(1)
else
position object 1, object position x(1), object position y(1)-3, object position z(1)
endif
` Print results, and see if ball is falling
set cursor 0, 0
print "Object speed X: "+str$(object position x(1)-oldX#)
print "Object speed Y: "+str$(object position y(1)-oldY#)
if object position y(1)-oldY# < 0 then print "Falling!"
` If ball has fallen off screen, replace it at starting position
if object position y(1) < -250 then position object 1, -45, 100, 0
sync
loop