8c69b3d678b4b07bc74b916e19630008df8c8014
[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 timer_get_left(timer_type* ptimer);
54 int timer_get_gone(timer_type* ptimer);
55 void timer_fwrite(timer_type* ptimer, FILE* fi);
56 void timer_fread(timer_type* ptimer, FILE* fi);
57
58 #endif /*SUPERTUX_TIMER_H*/
59
60 /* Local Variables: */
61 /* mode:c++ */
62 /* End */