Distance between a sprite and point
BlitzMax Forums/BlitzMax Programming/Distance between a sprite and point
| ||
I need a way to see how many frames it will take a sprite to reach a point on the screen. The sprite has a varaible that decreases every frame equal to the speed the sprite is travelling. So the sprite will keep moving towards the point until the variable is negative. What would I use to get the amount of frames the sprite will need to keep moving to reach the point? Thanks. |
| ||
What would I use to get the amount of frames the sprite will need to keep moving to reach the point? Division? The variable (remaining distance) / the speed (distance traveled each frame) = (remaining frames). |
| ||
Right. And the way to find the distance is best found with the help of good ol' Pythagoras. Distance = sqr(xDist^2 + yDist^2) That is the most important algorithm in games programming, in my humble, uninformed opinion. |
| ||
Thanks for all your help! |