Jump to content
  • Advertisement


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

bryan costanich

frame timer code

This topic is 5691 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
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.

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

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!