17 #ifndef HEADER_SUPERTUX_SUPERTUX_TIMER_HPP 18 #define HEADER_SUPERTUX_SUPERTUX_TIMER_HPP 20 #include "supertux/globals.hpp" 32 void start(
float period,
bool cyclic =
false);
49 float get_timeleft()
const {
return m_period - (g_game_time - m_cycle_start); }
50 float get_timegone()
const {
return g_game_time - m_cycle_start; }
51 float get_progress()
const {
return get_timegone() /
get_period(); }
52 bool started()
const {
return (m_period != 0 && get_timeleft() > 0); }
53 bool paused()
const {
return m_cycle_pause != 0; }
float get_period() const
returns the period of the timer or 0 if it isn't started
Definition: timer.hpp:48
void resume()
resume (unpause) the timer
Definition: timer.cpp:65
void start(float period, bool cyclic=false)
start the timer with the given period (in seconds).
Definition: timer.cpp:30
bool check()
returns true if a period (or more) passed since start call or last successful check ...
Definition: timer.cpp:39
void pause()
pause the timer
Definition: timer.cpp:57
Simple timer designed to be used in the update functions of objects.
Definition: timer.hpp:24
void stop()
stop the timer
Definition: timer.hpp:39