Many years ago I coded some AI for a budget pseudo-3d game. There was one calculation which I never really figured out the best way to do, and that was calculating where the enemy would end up if it stopped now. For example:
- The enemy is currently at X = 540.0.
- The enemy is moving right at 10 pixels per frame.
- When the enemy wants to stop, it's speed will drop by 1 pixel per frame until it reaches zero.
Is there a simple formula that would get me the position where the enemy ends up when he is fully stopped? I ended up precalculating and hardcoding the offset which worked for my needs but would have to be calculated separately for enemies with different speeds.