Jump to content
  • Advertisement

Archived

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

JIMbond21

Setting up a timer

This topic is 5461 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

In Win32 API there is a timer that I can make the put out a message and is check by WM_TIMER, but I have heard it isnt very accurate, so I was wondering how would I make a timer for a desired frame rate, without use the windows timer, and a funtion that works in a while loop that would, say, skip a frame cycle everytime it is called, that way I could have a while loop for the whole game and be able to control the speed of the animations and movements. THX, JAP

Share this post


Link to post
Share on other sites
Advertisement
Try using GetTickCount()

It counts the number of milliseconds since windows waas started.
Then you can use something like
start = GetTickCount()

//enter main loop
// draw frame, etc.

// wait until 33 milliseconds has elapsed
while(GetTickCount() - start) < 33);

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!