Fixed trailing whitespaces in all(?) source files of supertux, also fixed some svn...
[supertux.git] / src / object / tilemap.hpp
index cb87573..69a5b2a 100644 (file)
@@ -28,6 +28,9 @@
 #include "serializable.hpp"
 #include "math/vector.hpp"
 #include "video/drawing_context.hpp"
+#include "object/path.hpp"
+#include "object/path_walker.hpp"
+#include "script_interface.hpp"
 
 namespace lisp {
 class Lisp;
@@ -40,7 +43,7 @@ class Tile;
 /**
  * This class is reponsible for drawing the level tiles
  */
-class TileMap : public GameObject, public Serializable
+class TileMap : public GameObject, public Serializable, public ScriptInterface
 {
 public:
   TileMap();
@@ -53,13 +56,25 @@ public:
   virtual void update(float elapsed_time);
   virtual void draw(DrawingContext& context);
 
+  /** Move tilemap until at given node, then stop */
+  void goto_node(int node_no);
+
+  /** Start moving tilemap */
+  void start_moving();
+
+  /** Stop tilemap at next node */
+  void stop_moving();
+
+  virtual void expose(HSQUIRRELVM vm, SQInteger table_idx);
+  virtual void unexpose(HSQUIRRELVM vm, SQInteger table_idx);
+
   void set(int width, int height, const std::vector<unsigned int>& vec,
       int z_pos, bool solid);
 
   /** resizes the tilemap to a new width and height (tries to not destroy the
    * existing map)
    */
-  void resize(int newwidth, int newheight);
+  void resize(int newwidth, int newheight, int fill_id = 0);
 
   size_t get_width() const
   { return width; }
@@ -85,6 +100,11 @@ public:
   bool is_solid() const
   { return solid; }
 
+  /**
+   * Changes Tilemap's solidity, i.e. whether to consider it when doing collision detection.
+   */
+  void set_solid(bool solid = true);
+
   /// returns tile in row y and column y (of the tilemap)
   const Tile* get_tile(int x, int y) const;
   /// returns tile at position pos (in world coordinates)
@@ -112,21 +132,35 @@ public:
     return drawing_effect;
   }
 
+  /**
+   * Start fading the tilemap to opacity given by @c alpha.
+   * Destination opacity will be reached after @c seconds seconds.
+   */
+  void fade(float alpha, float seconds = 0);
+
 private:
   typedef std::vector<uint32_t> Tiles;
   Tiles tiles;
 
 private:
   TileManager* tilemanager;
-  std::string name;
   bool solid;
-  float speed;
+  float speed_x;
+  float speed_y;
   int width, height;
   int z_pos;
   float x_offset;
   float y_offset;
 
   DrawingEffect drawing_effect;
+  float alpha; /**< requested tilemap opacity */
+  float current_alpha; /**< current tilemap opacity */
+  float remaining_fade_time; /**< seconds until requested tilemap opacity is reached */
+
+  std::auto_ptr<Path> path;
+  std::auto_ptr<PathWalker> walker;
+
+  DrawingContext::Target draw_target; /**< set to LIGHTMAP to draw to lightmap */
 };
 
 #endif /*SUPERTUX_TILEMAP_H*/