]> git.localhorst.tv Git - l2e.git/blob - src/map/Area.h
d839e96c0688b3fbf91657bb152ef5e52a03db0d
[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         static const int TYPE_ID = 601;
26
27 public:
28         Area();
29         ~Area() { }
30
31 public:
32         /// Get the width in tiles.
33         int Width() const { return width; }
34         /// Get the height in tiles.
35         int Height() const { return numTiles / width + (numTiles % width ? 1 : 0); }
36         /// Get the size in tiles.
37         geometry::Vector<int> Size() const { return geometry::Vector<int>(Width(), Height()); }
38         /// Get a tile by tile coordinates (not pixel coordinates!).
39         Tile *TileAt(const geometry::Vector<int> &);
40         const Tile *TileAt(const geometry::Vector<int> &) const;
41
42         /// Get the default battle background for this area.
43         SDL_Surface *BattleBackground() { return battlebg; }
44
45         void Render(SDL_Surface *dest, const graphics::Sprite *tileset, const geometry::Vector<int> &offset) const;
46         void RenderDebug(SDL_Surface *dest, const graphics::Sprite *tileset, const geometry::Vector<int> &offset) const;
47
48         static void CreateTypeDescription();
49         static void Construct(void *);
50
51 // temporary setters
52 public:
53         void SetTiles(Tile *t, int num) { tiles = t; numTiles = num; }
54         void SetWidth(int w) { width = w; }
55
56 private:
57         SDL_Surface *battlebg;
58         Tile *tiles;
59         int numTiles;
60         int width;
61
62 };
63
64 }
65
66 #endif /* MAP_AREA_H_ */