• Advertisement

Archived

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

frame timer code

This topic is 5570 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
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

Share this post


Link to post
Share on other sites

  • Advertisement