]> git.localhorst.tv Git - l2e.git/blob - src/map/Map.h
removed stupid file headers that eclipse put in
[l2e.git] / src / map / Map.h
1 #ifndef MAP_MAP_H_
2 #define MAP_MAP_H_
3
4 #include "Entity.h"
5 #include "fwd.h"
6 #include "../geometry/Vector.h"
7 #include "../graphics/fwd.h"
8
9 #include <SDL.h>
10
11 namespace map {
12
13 /// Represents a single map in the game.
14 /// Maps are made up of uniform areas of tiles.
15 /// The looks of a tile is defined by the Tileset() sprite with Tile::Offset()
16 /// as the column and row in the sprite.
17 /// Maps can be propulated with triggers and entities. Those are or use with
18 /// MapState and are not handled by the map itself.
19 /// Positions are expressed either as pixel or tile coordinates depending on
20 /// function purpose with (0|0) being the top left corner and positive values
21 /// extending to the right and down respectively.
22 class Map {
23
24 public:
25         static const int TYPE_ID = 602;
26
27 public:
28         Map();
29         ~Map() { }
30
31 public:
32         /// The sprite used as the tileset.
33         const graphics::Sprite *Tileset() const { return tileset; }
34         /// Returns the Area at given pixel coordinates or 0 if off the map.
35         Area *AreaAt(const geometry::Vector<int> &);
36         const Area *AreaAt(const geometry::Vector<int> &) const;
37         /// Returns the Tile at given pixel coordinates or 0 if off the map.
38         Tile *TileAt(const geometry::Vector<int> &);
39         const Tile *TileAt(const geometry::Vector<int> &) const;
40         /// Returns the Trigger at given pixel coordinates or 0 if off the map.
41         /// Multiple triggers are not supported. The first one found is returned.
42         Trigger *TriggerAt(const geometry::Vector<int> &);
43         /// The battle background image for this map if neither the tile nor the
44         /// area has one specified.
45         SDL_Surface *BattleBackgroundAt(const geometry::Vector<int> &);
46         /// Convert coordinates pixel to tile.
47         geometry::Vector<int> TileCoordinates(const geometry::Vector<int> &) const;
48
49         Entity *EntitiesBegin() { return entities; }
50         Entity *EntitiesEnd() { return entities + numEntities; }
51
52         /// Render the map.
53         /// Entities are not rendered by this function.
54         void Render(SDL_Surface *dest, const geometry::Vector<int> &offset) const;
55         /// Render a debugging overlay that includes collision and trigger
56         /// information.
57         void RenderDebug(SDL_Surface *dest, const geometry::Vector<int> &offset) const;
58
59         static void CreateTypeDescription();
60         static void Construct(void *);
61
62 private:
63         const graphics::Sprite *tileset;
64         SDL_Surface *battlebg;
65         Area *areas;
66         int numAreas;
67         Trigger *triggers;
68         int numTriggers;
69         Entity *entities;
70         int numEntities;
71         int width;
72
73 };
74
75 }
76
77 #endif /* MAP_MAP_H_ */