- added standard copyright header to every file
[supertux.git] / src / timer.h
1 //  $Id$
2 // 
3 //  SuperTux
4 //  Copyright (C) 2004 Tobias Glaesser <tobi.web@gmx.de>
5 //
6 //  This program is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU General Public License
8 //  as published by the Free Software Foundation; either version 2
9 //  of the License, or (at your option) any later version.
10 //
11 //  This program is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //  GNU General Public License for more details.
15 // 
16 //  You should have received a copy of the GNU General Public License
17 //  along with this program; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 //  02111-1307, USA.
20
21 #ifndef SUPERTUX_TIMER_H
22 #define SUPERTUX_TIMER_H
23
24 extern unsigned int st_pause_ticks, st_pause_count;
25
26 unsigned int st_get_ticks(void);
27 void st_pause_ticks_init(void);
28 void st_pause_ticks_start(void);
29 void st_pause_ticks_stop(void);
30
31 class Timer
32 {
33  public:
34   unsigned int period;
35   unsigned int time;
36   unsigned int (*get_ticks) (void);  
37
38  public:
39   void init(bool st_ticks);
40   void start(unsigned int period);
41   void stop();
42
43   /*======================================================================
44     return: NO  = the timer is not started
45     or it is over
46     YES = otherwise
47     ======================================================================*/
48   int check();
49   int started();
50
51   /*======================================================================
52     return: the time left (in millisecond)
53     note  : the returned value can be negative
54     ======================================================================*/
55   int get_left();
56
57   int  get_gone();
58   void fwrite(FILE* fi);
59   void fread(FILE* fi);
60 };
61
62 #endif /*SUPERTUX_TIMER_H*/
63
64 /* Local Variables: */
65 /* mode:c++ */
66 /* End: */