moving images at angles

BlitzMax Forums/BlitzMax Beginners Area/moving images at angles

delusan(Posted 2007) [#1]
How would I move an image on a straight line between two points?
I understand simple vertical and horizontal movement, but am having trouble grasping movement at an angle.
I would like the image to move from (for example) x=500,y=500 to x=200,y=350.
Are there functions that move an image from point-to-point?


Gabriel(Posted 2007) [#2]
Get the angle with
Angle=Atan2(ToY-FromY,ToX-FromX)


and then move it by

X:+Cos(Angle)*Speed
Y:+Sin(Angle)*Speed


Of course, your position variables will need to be floating point to keep everything smooth.


delusan(Posted 2007) [#3]
Gabriel -
thank you - works perfectly!