Again timer...

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Isgalvotas
Posts: 13
Joined: Mon Oct 31, 2005 8:58 pm
Location: Lithuania
Contact:

Again timer...

Post by Isgalvotas »

Hello everybody,

Can someone share code example how to do frame-indipendant timer and implement it in Irrlicht? :idea: :?: I'm tired of trying to do this...waiting for any help :!:

Happy New Year,
Isgalvotas.
Image
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

#include <time.h>
//Timer
time_t TimeStamp;
tm *nun;
int now;
int before;

/////////////TIMER//////////////////////////////////////////////////////////////
TimeStamp = time(0);
nun = localtime(&TimeStamp);
now = nun->tm_sec;
before = nun->tm_sec;
////////////////////////////////////////////////////////////////////////////////

while(true)
{
//Time the timer!!!
if(now >= before+1)
{
before=now;
//Print time
cout<<before<<endl;
///////////////////////End Timer//////////////////////////////////
}
TimeStamp = time(0);
nun = localtime(&TimeStamp);
now = nun->tm_sec;
if(now == 0)
before=0;
}
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Isgalvotas
Posts: 13
Joined: Mon Oct 31, 2005 8:58 pm
Location: Lithuania
Contact:

Thanks

Post by Isgalvotas »

Thanx a lot for code! :) Now I have timer in my game. :P

Best wishes,
Isgalvotas.
Image
Post Reply