updated dispenser -- can summon mriceblock, snowball, bouncing_snowball and mrbomb now
[supertux.git] / src / tile.h
index e72fbee..f943a23 100644 (file)
 #ifndef TILE_H
 #define TILE_H
 
-#include <set>
-#include <map>
 #include <vector>
-#include "screen/texture.h"
-#include "globals.h"
-#include "lispreader.h"
-#include "setup.h"
-#include "polygon.h"
-#include "vector.h"
+#include "SDL.h"
+#include "video/surface.h"
 
+using namespace SuperTux;
+
+namespace SuperTux {
 class LispReader;
+}
 
 /**
 Tile Class
@@ -43,9 +41,9 @@ public:
   ~Tile();
 
   /// parses the tile and returns it's id number
-  int read(LispReader& reader);
+  void read(LispReader& reader);
 
-  int id;
+  unsigned int id;
 
   std::vector<Surface*> images;
   std::vector<Surface*> editor_images;
@@ -72,11 +70,13 @@ public:
        * if data is 0 then the endsequence should be triggered, if data is 1
        * then we can finish the level instantly.
        */
-      GOAL      = 0x0100
+      GOAL      = 0x0100,
+      /** slope tile */
+      SLOPE     = 0x0200
   };
 
   /** tile attributes */
-  uint32_t attributes;
+  Uint32 attributes;
   
   /** General purpose data attached to a tile (content of a box, type of coin)*/
   int data;
@@ -85,10 +85,10 @@ public:
       been collected or jumped at */
   int next_tile;
 
-  int anim_speed;
-  
-  /** Draw a tile on the screen: */
-  static void draw(const Vector& pos, unsigned int c, Uint8 alpha = 255);
+  float anim_fps;
+
+  /** Draw a tile on the screen */
+  void draw(DrawingContext& context, const Vector& pos, int layer) const;
 
   /// returns the width of the tile in pixels
   int getWidth() const
@@ -107,53 +107,6 @@ public:
   }
 };
 
-struct TileGroup
-{
-  friend bool operator<(const TileGroup& lhs, const TileGroup& rhs)
-  { return lhs.name < rhs.name; };
-  friend bool operator>(const TileGroup& lhs, const TileGroup& rhs)
-  { return lhs.name > rhs.name; };
-
-  std::string name;
-  std::vector<int> tiles;
-};
-
-class TileManager
-{
- private:
-  TileManager();
-  ~TileManager();
-  
-  std::vector<Tile*> tiles;
-  static TileManager* instance_ ;
-  static std::set<TileGroup>* tilegroups_;
-  void load_tileset(std::string filename);
-
-  std::string current_tileset;
-  
- public:
-  static TileManager* instance()
-  { return instance_ ? instance_ : instance_ = new TileManager(); }
-  static void destroy_instance()
-  { delete instance_; instance_ = 0; }
-
-  void draw_tile(DrawingContext& context, unsigned int id,
-      const Vector& pos, int layer);
-  
-  static std::set<TileGroup>* tilegroups() { if(!instance_) { instance_ = new TileManager(); } return tilegroups_ ? tilegroups_ : tilegroups_ = new std::set<TileGroup>; }
-  Tile* get(unsigned int id) {
-    if(id < tiles.size())
-      {
-        return tiles[id]; 
-      }
-    else
-      {
-        // Never return 0, but return the 0th tile instead so that
-        // user code doesn't have to check for NULL pointers all over
-        // the place
-        return tiles[0]; 
-      } 
-  }
-};
-
 #endif
+
+/* EOF */