Archived

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

JIMbond21

Setting up a timer

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