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