moving images at angles
BlitzMax Forums/BlitzMax Beginners Area/moving images at angles
| ||
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? |
| ||
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. |
| ||
Gabriel - thank you - works perfectly! |