- moved loadshared() to the right point
[supertux.git] / src / gameloop.h
index 542b7b1..27f6ce1 100644 (file)
@@ -16,6 +16,7 @@
 #include "sound.h"
 #include "type.h"
 #include "level.h"
+#include "world.h"
 
 /* GameLoop modes */
 
 #define ST_GL_LOAD_GAME 2
 #define ST_GL_LOAD_LEVEL_FILE  3
 
-// FIXME: Make this local to the gamesession
-extern Level current_level;
-
 extern int game_started;
 
+class World;
+
+/** The GameSession class controlls the controll flow of a World, ie.
+    present the menu on specifc keypresses, render and update it while
+    keeping the speed and framerate sane, etc. */
 class GameSession
 {
  private:
-    timer_type fps_timer, frame_timer;
+  bool quit;
+  Timer fps_timer;
+  Timer frame_timer;
+  World* world;
+  int st_gl_mode;
+
+  float fps_fps;
+  unsigned int last_update_time;
+  unsigned int update_time;
+  int pause_menu_frame;
+  int debug_fps;
+  bool game_pause;
+
+  // FIXME: Hack for restarting the level
+  std::string subset;
+  int levelnb;
+
  public:
-  GameSession(const char * subset, int levelnb, int mode);
-  int run();
-};
+  Timer time_left;
 
-void  activate_bad_guys(Level* plevel);
-void  savegame(int slot);
-void  loadgame(int slot);
-std::string slotinfo(int slot);
+  GameSession();
+  GameSession(const std::string& filename);
+  GameSession(const std::string& subset, int levelnb, int mode);
+  ~GameSession();
 
-bool  rectcollision(base_type* one, base_type* two);
-void  drawshape(float x, float y, unsigned int c, Uint8 alpha = 255);
-void bumpbrick(float x, float y);
+  /** Enter the busy loop */
+  int  run();
 
-/** Try to grab the coin at the given coordinates */
-void trygrabdistro(float x, float y, int bounciness);
+  void draw();
+  int  action(double frame_ratio);
 
-/** Try to break the brick at the given coordinates */
-void trybreakbrick(float x, float y, bool small);
+  Level* get_level() { return world->get_level(); }
+  World* get_world() { return world; }
 
-/** Try to get the content out of a bonus box, thus emptying it */
-void tryemptybox(float x, float y, int col_side);
+  void  savegame(int slot);
+  void  loadgame(int slot);
 
-/** Try to bumb a badguy that might we walking above Tux, thus shaking
-    the tile which the badguy is walking on an killing him this way */
-void trybumpbadguy(float x, float y);
+  static GameSession* current() { return current_; }
+ private:
+  static GameSession* current_;
+
+  void init();
+
+  void start_timers();
+  void process_events();
+
+  void levelintro();
+  void drawstatus();
+  void drawendscreen();
+  void drawresultscreen(void);
+};
+
+std::string slotinfo(int slot);
+
+bool rectcollision(base_type* one, base_type* two);
+void bumpbrick(float x, float y);
 
 #endif /*SUPERTUX_GAMELOOP_H*/