Skip to main content
gamedev.net
🔒 Locked

Newbie- Timer Question

Started by Squizz 1 reply 550+ views
Original Post
Squizz
Squizz
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
Squizz-Repaint the World
Julio
Julio
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.
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
Midnight Coder
Midnight Coder
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.