0d03ccb1941db26ec51c97aa4eaffc26d83dfd77
[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_type
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     int timer_check(timer_type* ptimer);
37     
38     param : pointer to a timer which needs to be checked
39     return: NO  = the timer is not started
40     or it is over
41     YES = otherwise
42     ======================================================================*/
43   int check();
44   int started();
45
46   /*======================================================================
47     int timer_get_left(timer_type* ptimer);
48
49     param : pointer to a timer that you want to get the time left
50     return: the time left (in millisecond)
51     note  : the returned value can be negative
52     ======================================================================*/
53   int get_left();
54
55   int  get_gone();
56   void fwrite(FILE* fi);
57   void fread(FILE* fi);
58 };
59
60 #endif /*SUPERTUX_TIMER_H*/
61
62 /* Local Variables: */
63 /* mode:c++ */
64 /* End */