]> git.localhorst.tv Git - l2e.git/blob - src/map/Area.h
some commenting on the map classes
[l2e.git] / src / map / Area.h
1 /*
2  * Area.h
3  *
4  *  Created on: Sep 26, 2012
5  *      Author: holy
6  */
7
8 #ifndef MAP_AREA_H_
9 #define MAP_AREA_H_
10
11 #include "fwd.h"
12 #include "../geometry/Vector.h"
13 #include "../graphics/Sprite.h"
14
15 #include <SDL.h>
16
17 namespace map {
18
19 /// Defines a rectangular section of a map.
20 /// Tiles are rendered ltr with a row break each width tiles.
21 /// Missing tiles in the last row are possible but don't fool yourself.
22 class Area {
23
24 public:
25         Area();
26         ~Area() { }
27
28 public:
29         /// Get the width in tiles.
30         int Width() const { return width; }
31         /// Get the height in tiles.
32         int Height() const { return numTiles / width + (numTiles % width ? 1 : 0); }
33         /// Get the size in tiles.
34         geometry::Vector<int> Size() const { return geometry::Vector<int>(Width(), Height()); }
35         /// Get a tile by tile coordinates (not pixel coordinates!).
36         Tile *TileAt(const geometry::Vector<int> &);
37         const Tile *TileAt(const geometry::Vector<int> &) const;
38
39         /// Get the default battle background for this area.
40         SDL_Surface *BattleBackground() { return battlebg; }
41
42         void Render(SDL_Surface *dest, const graphics::Sprite *tileset, const geometry::Vector<int> &offset) const;
43         void RenderDebug(SDL_Surface *dest, const graphics::Sprite *tileset, const geometry::Vector<int> &offset) const;
44
45         static void CreateTypeDescription();
46         static void Construct(void *);
47
48 // temporary setters
49 public:
50         void SetTiles(Tile *t, int num) { tiles = t; numTiles = num; }
51         void SetWidth(int w) { width = w; }
52
53 private:
54         SDL_Surface *battlebg;
55         Tile *tiles;
56         int numTiles;
57         int width;
58
59 };
60
61 }
62
63 #endif /* MAP_AREA_H_ */