1 #ifndef __SUPERTUX_TIMER_H__
2 #define __SUPERTUX_TIMER_H__
4 extern float global_time;
7 * new simpler timer designed to be used in the update functions of objects
9 class Timer2 // TODO rename later
15 /** start the timer with the given period (in seconds).
16 * If cyclic=true then the timer willl be reset after each period.
17 * Set period to zero if you want to disable the timer.
19 void start(float period, bool cyclic = false);
20 /** returns true if a period (or more) passed since start call or last
25 /** returns the period of the timer or 0 if it isn't started */
26 float get_period() const
28 float get_timeleft() const
29 { return period - (global_time - cycle_start); }
30 float get_timegone() const
31 { return global_time - cycle_start; }
33 { return period != 0 && get_timeleft() > 0; }