Page 1 of 1

Again timer...

Posted: Fri Dec 30, 2005 3:09 pm
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.

Posted: Fri Dec 30, 2005 4:01 pm
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;
}

Thanks

Posted: Sun Jan 01, 2006 1:25 pm
by Isgalvotas
Thanx a lot for code! :) Now I have timer in my game. :P

Best wishes,
Isgalvotas.