Distance between a sprite and point

BlitzMax Forums/BlitzMax Programming/Distance between a sprite and point

wizenick(Posted 2007) [#1]
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.


FlameDuck(Posted 2007) [#2]
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).


Dubious Drewski(Posted 2007) [#3]
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.


wizenick(Posted 2007) [#4]
Thanks for all your help!