yeti cleanup and death animation rework, hitbox fix ups
[supertux.git] / src / worldmap.hpp
index a6a1c66..741863c 100644 (file)
@@ -1,7 +1,8 @@
 //  $Id$
-// 
+//
 //  SuperTux
 //  Copyright (C) 2004 Ingo Ruhnke <grumbel@gmx.de>
+//  Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
 //
 //  This program is free software; you can redistribute it and/or
 //  modify it under the terms of the GNU General Public License
@@ -12,7 +13,7 @@
 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 //  GNU General Public License for more details.
-// 
+//
 //  You should have received a copy of the GNU General Public License
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "control/controller.hpp"
 #include "statistics.hpp"
 #include "timer.hpp"
+#include "screen.hpp"
 #include "tile_manager.hpp"
 #include "game_object.hpp"
+#include "console.hpp"
 
 class Sprite;
 class Menu;
@@ -80,6 +83,12 @@ private:
   bool  moving;
 
   void stop();
+
+  bool canWalk(const Tile* tile, Direction dir); /**< check if we can leave "tile" in direction "dir" */
+  void updateInputDirection(); /**< if controller was pressed, update input_direction */
+  void tryStartWalking(); /**< try starting to walk in input_direction */
+  void tryContinueWalking(float elapsed_time); /**< try to continue walking in current direction */
+
 public: 
   Tux(WorldMap* worldmap_);
   ~Tux();
@@ -96,17 +105,18 @@ public:
 };
 
 /** */
-class WorldMap
+class WorldMap : public Screen
 {
 private:
   Tux* tux;
 
-  bool quit;
-
   Surface* leveldot_green;
   Surface* leveldot_red;
   Surface* messagedot;
-  Surface* teleporterdot;
+  Sprite* teleporterdot;
+  static WorldMap* current_;
+
+  Vector camera_offset;
 
   std::string name;
   std::string music;
@@ -116,6 +126,8 @@ private:
   TileMap* solids;
   
   TileManager* tile_manager;
+  
+  Console* console;
 
 public:
   struct SpecialTile
@@ -124,6 +136,9 @@ public:
 
     /** Optional flags: */
 
+    /** Sprite to render instead of guessing what image to draw */
+    Sprite* sprite;
+
     /** Position to swap to player */
     Vector teleport_dest;
 
@@ -149,6 +164,8 @@ public:
     std::string title;
     bool solved;
 
+    Sprite* sprite;
+
     /** Statistics for level tiles */
     Statistics statistics;
 
@@ -210,16 +227,16 @@ public:
   WorldMap();
   ~WorldMap();
 
-  /** Busy loop */
-  void display();
-
   void load_map();
   
-  void get_input();
-
   void add_object(GameObject* object);
   void clear_objects();
 
+  static WorldMap* current()
+  { return current_; }
+
+  void setup();
+
   /** Update Tux position */
   void update(float delta);
 
@@ -229,6 +246,15 @@ public:
   Vector get_next_tile(Vector pos, Direction direction);
   const Tile* at(Vector pos);
 
+  size_t level_count();
+  size_t solved_level_count();
+
+  /**
+   * gets called from the GameSession when a level has been successfully
+   * finished
+   */
+  void finished_level(const std::string& filename);
+
   WorldMap::Level* at_level();
   WorldMap::SpecialTile* at_special_tile();
 
@@ -236,15 +262,20 @@ public:
       if possible, write the new position to \a new_pos */
   bool path_ok(Direction direction, Vector pos, Vector* new_pos);
 
-  /* Save map to slot */
-  void savegame(const std::string& filename);
-  /* Load map from slot
-     You should call set_map_filename() before this */
-  void loadgame(const std::string& filename);
-  /* Load map directly from file */
+  /**
+   * Save worldmap state to squirrel state table
+   */
+  void save_state();
+  /**
+   * Load worldmap state from squirrel state table
+   */
+  void load_state();
+  /**
+   * Load a worldmap
+   */
   void loadmap(const std::string& filename);
 
-  const std::string& get_world_title() const
+  const std::string& get_title() const
   { return name; }
     
   void set_map_filename(std::string filename)