Archived

This topic is now archived and is closed to further replies.

bryan costanich

frame timer code

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites