- moved stuff from scene into a World class, just an intermediate step, more cleanup...
[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 /** The GameSession class controlls the controll flow of a World, ie.
30     present the menu on specifc keypresses, render and update it while
31     keeping the speed and framerate sane, etc. */
32 class GameSession
33 {
34  private:
35   timer_type fps_timer, frame_timer;
36   Level current_level;
37
38  public:
39   GameSession();
40   GameSession(const std::string& filename);
41   GameSession(const std::string& subset, int levelnb, int mode);
42   int  run();
43   void draw();
44   int  action();
45   void process_events();
46
47   Level* get_level() { return &current_level; }
48
49   void  savegame(int slot);
50   void  loadgame(int slot);
51
52   static GameSession* current() { return current_; }
53  private:
54   static GameSession* current_;
55
56   void levelintro();
57   void start_timers();
58   void activate_particle_systems();
59 };
60
61 void  activate_bad_guys(Level* plevel);
62
63 std::string slotinfo(int slot);
64
65 bool  rectcollision(base_type* one, base_type* two);
66 void  drawshape(float x, float y, unsigned int c, Uint8 alpha = 255);
67 void bumpbrick(float x, float y);
68
69 #endif /*SUPERTUX_GAMELOOP_H*/
70