frame timer code

Started by
1 comment, last by bryan costanich 21 years, 6 months ago
what is a good way to base frame movement off a constant interval? for example, if i just put frameMove() { // some rotation code something.rotate } the rotation speed depends on the frame rate.. what would be a good way to base it off a constant time interval? -b
-b
Advertisement
Frame rates will rarely give you a constant interval. I can only advise an alternate method.

Keep track of the difference in time between frames and make your your rotation time dependent and frame independent.

e.g.
frameMove()
{
deltaTime = currentTime - timeOnLastFrame;

// This uses seconds as an example though it
// may be easier to work with milliseconds
rotation = radsPerSecond * deltaTime;

timeOnLastFrame = currentTime;
}


This is a very simple example you''ll need to modify it to suit your needs.

Chris Z.
ZeroFX Interactive
Chris Z. GPU FX
cool. thanks!

-b
-b

This topic is closed to new replies.

Advertisement