im trying to get a sprite to fly towards the mouse when the left click is released. im having trouble figuring out how to get it to calculate the angle inwhich it needs to be moving in to fly towards mouse. anyone know how i could calculate this angle?
Ernest Friedman-Hill
author and iconoclast
Marshal
Where delta_x/y are the amounts to add to the x and y coordinates of the sprite in each frame of animation, mouse_x/y are the mouse coordinates, sprite_x/y are the sprite's coordinates, and f() is some function that determines the speed of motion -- it might be "divide by 5, rounding up", for example.
The actual angle isn't as useful, but if you truly need it, it's
you need to be careful of that potential divide-by-zero; if the denominator is 0, then the angle is either 0 or pi, depending on the sign of the numerator.