Renamed Rect to Rectf
[supertux.git] / src / supertux / tile.hpp
index 3e13d9b..690aef3 100644 (file)
 #ifndef HEADER_SUPERTUX_SUPERTUX_TILE_HPP
 #define HEADER_SUPERTUX_SUPERTUX_TILE_HPP
 
-#include <stdint.h>
 #include <vector>
+#include <stdint.h>
 
-#include "math/rect.hpp"
+#include "math/rectf.hpp"
 #include "video/surface.hpp"
 #include "util/reader_fwd.hpp"
 
 class TileSet;
 class DrawingContext;
 
-/**
-   Tile Class
-*/
 class Tile
 {
 public:
@@ -86,16 +83,16 @@ public:
   };
 
   struct ImageSpec {
-    ImageSpec(const std::string& newfile, const Rect& newrect)
+    ImageSpec(const std::string& newfile, const Rectf& newrect)
       : file(newfile), rect(newrect)
     { }
 
     std::string file;
-    Rect rect;
+    Rectf rect;
   };
 
 private:
-  const TileSet         *tileset;
+  const TileSet&         tileset;
   std::vector<ImageSpec> imagespecs;
   std::vector<Surface*>  images;
 
@@ -108,8 +105,14 @@ private:
   float anim_fps;
 
 public:
+  Tile(const TileSet& tileset);
+  Tile(const TileSet& tileset, const std::vector<ImageSpec>& images,
+       uint32_t attributes, uint32_t data, float animfps);
   ~Tile();
 
+  /** load Surfaces, if not already loaded */
+  void load_images();
+
   /** Draw a tile on the screen */
   void draw(DrawingContext& context, const Vector& pos, int z_pos) const;
 
@@ -119,34 +122,9 @@ public:
   int getData() const
   { return data; }
 
-  /// returns the width of the tile in pixels
-  int getWidth() const
-  {
-    if(!images.size())
-      return 0;
-    return (int) images[0]->get_width();
-  }
-
-  /// returns the height of the tiles in pixels
-  int getHeight() const
-  {
-    if(!images.size())
-      return 0;
-    return (int) images[0]->get_height();
-  }
-
-protected:
-  friend class TileSet;
-  Tile(const TileSet *tileset);
-  Tile(const TileSet *tileset, std::vector<std::string> images, Rect rect,
-       uint32_t attributes = 0, uint32_t data = 0, float animfps = 1.0);
-
-  void load_images();
-
-  /// parses the tile and returns it's id number
-  uint32_t parse(const Reader& reader);
-  void parse_images(const Reader& cur);
+  void print_debug(int id) const;
 
+private:
   //Correct small oddities in attributes that naive people
   //might miss (and rebuke them for it)
   void correct_attributes();