When tile&pixel position math goes wrong?..

Started by
11 comments, last by Dave Hunt 19 years, 1 month ago
I'd try just starting over. Redo these code snippets WITHOUT looking at the original... I find that it often helps me solve some problem...
BRING BACK THE BLACK (or at least something darker)
Advertisement
Allow me to explain the integer float division thing..

What I'm *trying* to do is get a representative value of the framerate the user's computer is rendering at. That way I can make smoother animations - and also a smooth change in distance!, but to be honest, I'm not sure I'm going about it in any way near correct.

Any ideas on that?
Join us at: http://www.blade2k.net/piracysucks/to help stop game piracy!
The method of frame rate calculation seems to be ok, you just need to use floating point throughout. The conversion to integer should be delayed as long as possible to limit precision loss. As it is, you have int3 = int1 / int2 where int2 is larger than int1. Since all of the variables involved are integers, the result is going to be zero.

I would recommend using floating point for your x/y positions. Otherwise, any movements of less than a full pixel will get truncated to zero and not accumulate across frames and could make the sprite not move at all.

This topic is closed to new replies.

Advertisement