Jump to content
  • Advertisement

Archived

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

Squizz

Newbie- Timer Question

This topic is 6199 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 the quickest and simplest way to get a timer counting in my program NOT USING MFC... just like a very quick and EASY way. All it needs to do is regulate a game loop. Thnkz in Advance

Share this post


Link to post
Share on other sites
Advertisement
check out my timer class on my page. it should have everything you need.



How many Microsoft employees does it take to screw in a light bulb?
None, they just declare drakness as a new standard.

Share this post


Link to post
Share on other sites
You can make your own timer system. Just get the amount of time it takes to render a frame, and then you can use that to tell how much time is passed. Like this:

  
int frametime;
int lasttime;
int timer;

void Init(void)
{
//Do initalization...

lasttime = timeGetTime();
frametime = 0;
timer = 0;
//More initialization...

}

void GameMain(void)
{
timer += frametime;
while(timer >= MAX_TIME) //MAX_TIME can be anything

{
timer -= MAX_TIME;
DoWhatever();
}

DoPhysics();
RenderFrame();
//Etc.


frametime = timeGetTime() - lasttime;
lasttime = timeGetTime();
}


This method works very well. The while loop is to ensure it doesn''t fall behind when the framerate drops.

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!