I would suggest that you look at locating the start point and target point then working off the vector between the two that you can use to move along.
Code: Select all
put field "Speed" into tSpeed --where speed is in pixels per second--
repeat until tStartPoint = tEndPoint
put the location of --cell-- into tStartPoint
put the location of --target-- into tEndPoint
put 0.1 into tTime --this will redraw the screen every 1/10 sec or 10 times per second. 0.01 is 1/100th second, etc change as necessary--
put tSpeed*tTime into tDist
-- work out the angle between the two--
put atan((item 2 of tEndPoint-item2 of tStartPoint)/(item 1 of tEndPoint-item1 of tStartPoint)) into tAngle
-- move the cell to a point that is a distance along the vector
move --cell-- to round((item 1 of tStartpoint)+ tDist * cos(tAngle)),round((item 2 of tStartpoint)+ tDist * sin(tAngle))
wait for tTime seconds
end repeat
You will just need a certain speed to move it (in a field on your card, and the right thing to call --cell-- (i.e. img "Cell" or grc "Cell") and --target--
Would also help if you had an out clause to make sure the function doesn't just run forever.
Have a play with it and see if that does what you want. If it doesn't I am sure it can be tweaked pretty easily. Like I said, I haven't tested it, so it could have some bugs, but theoretically it could work.
X