Added inverse functions for speed. Might be usefull for someone that wants to make...
[supertux.git] / src / timer.h
1 //
2 // C Interface: timer
3 //
4 // Description: 
5 //
6 //
7 // Author: Tobias Glaesser <tobi.web@gmx.de>, (C) 2004
8 //
9 // Copyright: See COPYING file that comes with this distribution
10 //
11 //
12
13 #ifndef SUPERTUX_TIMER_H
14 #define SUPERTUX_TIMER_H
15
16 extern unsigned int st_pause_ticks, st_pause_count;
17
18 unsigned int st_get_ticks(void);
19 void st_pause_ticks_init(void);
20 void st_pause_ticks_start(void);
21 void st_pause_ticks_stop(void);
22
23 class Timer
24 {
25  public:
26   unsigned int period;
27   unsigned int time;
28   unsigned int (*get_ticks) (void);  
29
30  public:
31   void init(bool st_ticks);
32   void start(unsigned int period);
33   void stop();
34
35   /*======================================================================
36     return: NO  = the timer is not started
37     or it is over
38     YES = otherwise
39     ======================================================================*/
40   int check();
41   int started();
42
43   /*======================================================================
44     return: the time left (in millisecond)
45     note  : the returned value can be negative
46     ======================================================================*/
47   int get_left();
48
49   int  get_gone();
50   void fwrite(FILE* fi);
51   void fread(FILE* fi);
52 };
53
54 #endif /*SUPERTUX_TIMER_H*/
55
56 /* Local Variables: */
57 /* mode:c++ */
58 /* End: */