4806aeba963ce857698e707b8b515c8214ab20ed
[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 #include "world.h"
20
21 /* GameLoop modes */
22
23 #define ST_GL_PLAY 0
24 #define ST_GL_TEST 1
25 #define ST_GL_LOAD_GAME 2
26 #define ST_GL_LOAD_LEVEL_FILE  3
27
28 extern int game_started;
29
30 class World;
31
32 /** The GameSession class controlls the controll flow of a World, ie.
33     present the menu on specifc keypresses, render and update it while
34     keeping the speed and framerate sane, etc. */
35 class GameSession
36 {
37  private:
38   timer_type fps_timer, frame_timer;
39   World* world;
40
41  public:
42   GameSession();
43   GameSession(const std::string& filename);
44   GameSession(const std::string& subset, int levelnb, int mode);
45   
46   int  run();
47   void draw();
48   int  action();
49   void process_events();
50
51   Level* get_level() { return world->get_level(); }
52   World* get_world() { return world; }
53
54   void  savegame(int slot);
55   void  loadgame(int slot);
56
57   static GameSession* current() { return current_; }
58  private:
59   static GameSession* current_;
60
61   void levelintro();
62   void start_timers();
63 };
64
65 void  activate_bad_guys(Level* plevel);
66
67 std::string slotinfo(int slot);
68
69 bool  rectcollision(base_type* one, base_type* two);
70 void  drawshape(float x, float y, unsigned int c, Uint8 alpha = 255);
71 void bumpbrick(float x, float y);
72
73 #endif /*SUPERTUX_GAMELOOP_H*/
74