]> git.localhorst.tv Git - l2e.git/blobdiff - src/map/Area.h
some commenting on the map classes
[l2e.git] / src / map / Area.h
index 9bca341c11fdbd6d977f7a042e8da98e63e10a12..9da3083b3fb42f2a7db9f627327cbab9afdb66a4 100644 (file)
@@ -8,18 +8,17 @@
 #ifndef MAP_AREA_H_
 #define MAP_AREA_H_
 
+#include "fwd.h"
 #include "../geometry/Vector.h"
+#include "../graphics/Sprite.h"
 
 #include <SDL.h>
 
-namespace graphics {
-       class Sprite;
-}
-
 namespace map {
 
-class Tile;
-
+/// Defines a rectangular section of a map.
+/// Tiles are rendered ltr with a row break each width tiles.
+/// Missing tiles in the last row are possible but don't fool yourself.
 class Area {
 
 public:
@@ -27,18 +26,33 @@ public:
        ~Area() { }
 
 public:
+       /// Get the width in tiles.
        int Width() const { return width; }
+       /// Get the height in tiles.
        int Height() const { return numTiles / width + (numTiles % width ? 1 : 0); }
+       /// Get the size in tiles.
+       geometry::Vector<int> Size() const { return geometry::Vector<int>(Width(), Height()); }
+       /// Get a tile by tile coordinates (not pixel coordinates!).
+       Tile *TileAt(const geometry::Vector<int> &);
+       const Tile *TileAt(const geometry::Vector<int> &) const;
+
+       /// Get the default battle background for this area.
+       SDL_Surface *BattleBackground() { return battlebg; }
 
        void Render(SDL_Surface *dest, const graphics::Sprite *tileset, const geometry::Vector<int> &offset) const;
+       void RenderDebug(SDL_Surface *dest, const graphics::Sprite *tileset, const geometry::Vector<int> &offset) const;
+
+       static void CreateTypeDescription();
+       static void Construct(void *);
 
 // temporary setters
 public:
-       void SetTiles(const Tile *t, int num) { tiles = t; numTiles = num; }
+       void SetTiles(Tile *t, int num) { tiles = t; numTiles = num; }
        void SetWidth(int w) { width = w; }
 
 private:
-       const Tile *tiles;
+       SDL_Surface *battlebg;
+       Tile *tiles;
        int numTiles;
        int width;