make GetTimeSinceStart static

This commit is contained in:
Glenn Maynard
2002-12-19 23:00:57 +00:00
parent 0c07c7d8c3
commit fc4c1637ba
2 changed files with 9 additions and 3 deletions
+7 -2
View File
@@ -23,13 +23,18 @@ const float SECS_IN_DAY = 60*60*24;
/* XXX: SDL_GetTicks() wraps every month or so. Handle it. */ /* XXX: SDL_GetTicks() wraps every month or so. Handle it. */
RageTimer::RageTimer() RageTimer::RageTimer()
{
Init();
GetDeltaTime(); /* so the next call to GetDeltaTime is from the construction of this object */
}
void RageTimer::Init()
{ {
static bool SDL_Initialized = false; static bool SDL_Initialized = false;
if(!SDL_Initialized) { if(!SDL_Initialized) {
SDL_InitSubSystem(SDL_INIT_TIMER); SDL_InitSubSystem(SDL_INIT_TIMER);
SDL_Initialized = true; SDL_Initialized = true;
} }
GetDeltaTime(); /* so the next call to GetDeltaTime is from the construction of this object */
} }
float RageTimer::GetDeltaTime() float RageTimer::GetDeltaTime()
@@ -46,7 +51,7 @@ float RageTimer::PeekDeltaTime() const
return (SDL_GetTicks() - m_iLastDeltaTime) / 1000.f; return (SDL_GetTicks() - m_iLastDeltaTime) / 1000.f;
} }
float RageTimer::GetTimeSinceStart() const float RageTimer::GetTimeSinceStart()
{ {
return SDL_GetTicks() / 1000.f; return SDL_GetTicks() / 1000.f;
} }
+2 -1
View File
@@ -19,9 +19,10 @@ public:
unsigned int GetTicks(); unsigned int GetTicks();
float GetDeltaTime(); // time between last call to GetDeltaTime() float GetDeltaTime(); // time between last call to GetDeltaTime()
float PeekDeltaTime() const; float PeekDeltaTime() const;
float GetTimeSinceStart() const; // seconds since the program was started static float GetTimeSinceStart(); // seconds since the program was started
private: private:
static void Init();
int m_iLastDeltaTime; int m_iLastDeltaTime;
}; };