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