c0dfe0756b0e2a70574848dbcc0d06c9f8f3284b
[supertux.git] / src / gameloop.h
1 /*
2   gameloop.h
3   
4   Super Tux - Game Loop!
5   
6   by Bill Kendrick & Tobias Glaesser <tobi.web@gmx.de>
7   bill@newbreedsoftware.com
8   http://www.newbreedsoftware.com/supertux/
9   
10   April 11, 2000 - March 15, 2004
11 */
12
13 #ifndef SUPERTUX_GAMELOOP_H
14 #define SUPERTUX_GAMELOOP_H
15
16 #include "sound.h"
17 #include "type.h"
18 #include "level.h"
19
20 /* GameLoop modes */
21
22 #define ST_GL_PLAY 0
23 #define ST_GL_TEST 1
24 #define ST_GL_LOAD_GAME 2
25 #define ST_GL_LOAD_LEVEL_FILE  3
26
27 extern int game_started;
28
29 class GameSession
30 {
31  private:
32   timer_type fps_timer, frame_timer;
33   Level current_level;
34
35  public:
36   GameSession();
37   GameSession(const std::string& filename);
38   GameSession(const std::string& subset, int levelnb, int mode);
39   int  run();
40   void draw();
41   int  action();
42   void process_events();
43
44   Level* get_level() { return &current_level; }
45
46   void  savegame(int slot);
47   void  loadgame(int slot);
48
49   static GameSession* current() { return current_; }
50  private:
51   static GameSession* current_;
52
53   void levelintro();
54   void start_timers();
55   void activate_particle_systems();
56 };
57
58 void  activate_bad_guys(Level* plevel);
59
60 std::string slotinfo(int slot);
61
62 bool  rectcollision(base_type* one, base_type* two);
63 void  drawshape(float x, float y, unsigned int c, Uint8 alpha = 255);
64 void bumpbrick(float x, float y);
65
66 #endif /*SUPERTUX_GAMELOOP_H*/
67