29 #include "nomlib/system/Timer.hpp"
37 if ( SDL_WasInit( SDL_INIT_TIMER ) ==
false )
39 if ( SDL_InitSubSystem ( SDL_INIT_TIMER ) == -1 )
41 NOM_LOG_ERR ( NOM, SDL_GetError() );
52 Timer::~Timer (
void )
56 SDL_QuitSubSystem ( SDL_INIT_TIMER );
59 void Timer::start (
void )
66 void Timer::stop (
void )
78 void Timer::pause (
void )
87 void Timer::unpause (
void )
97 uint32 Timer::ticks (
void )
const
115 bool Timer::started (
void )
const
120 bool Timer::paused (
void )
const
125 const std::string Timer::ticksAsString (
void )
const
127 return std::to_string ( static_cast<uint32> ( this->ticks() ) );
132 return static_cast<uint32
> ( milliseconds * 1000.f );
uint32 paused_ticks
Holds ticks while paused.
void restart(void)
Alias for start.
bool timer_paused
Tracks whether we are paused or not.
uint32 elapsed_ticks
Milliseconds since timer start.
uint32 seconds(float milliseconds) const
Helper method; conversion from milliseconds to seconds.
bool timer_started
Tracks whether we are started or not.