by Dan East » Jul 7, 2004 @ 6:22pm
As Thierry said, fixed point math is completely the way to go. You also want to avoid division like the plague. I also try to avoid multiplication whenever possible too.
Here's a quick example on the time based deal. Instead of using fractions of a second, just use millseconds. Further, use 1024 milliseconds per second, because precision-wise that is usually completely fine, and you can shift right by 10 instead of dividing by 1000.
So say an object is moving 500 units per second, and 20 mS has elapsed over the last frame. So the actual units to move this frame are:
(50*20)>>10 = 9 units
Dan East