Definition at line 12 of file TimerAgent.h.
Public Member Functions | |
Uint32 | getDeltaTime () const |
int | getCycles () const |
Protected Member Functions | |
virtual void | own_init () |
virtual void | own_update () |
Sleep fixed number miliseconds. |
|
Definition at line 27 of file TimerAgent.h. 00027 { return m_count; }
|
|
Definition at line 26 of file TimerAgent.h. 00026 { return m_deltaTime; }
|
|
Reimplemented from BaseAgent. Definition at line 15 of file TimerAgent.cpp. 00016 {
00017 m_timeinterval = OptionAgent::agent()->getAsInt("timeinterval", 100);
00018 m_lastTime = SDL_GetTicks();
00019 m_nextTime = m_lastTime;
00020 m_deltaTime = 1;
00021 m_count = 0;
00022 }
|
|
Sleep fixed number miliseconds.
Reimplemented from BaseAgent. Definition at line 42 of file TimerAgent.cpp. 00043 { 00044 m_count++; 00045 00046 Uint32 now = SDL_GetTicks(); 00047 if (now < m_nextTime) { 00048 SDL_Delay(m_nextTime - now); 00049 } 00050 00051 now = SDL_GetTicks(); 00052 //NOTE: every cycle have fixed time interval 00053 m_nextTime = now + getTimeInterval(); 00054 00055 m_deltaTime = now - m_lastTime; 00056 m_lastTime = now; 00057 }
|