X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmap%2FMap.h;h=101689f72c43f9ecece1748100f90b9aa4bfc5ed;hb=092a2dd175a4001a495c84ee85211734fb928c83;hp=5eacc7b9b08e15ba2c3d4968debc6793a97811b0;hpb=0ad5ca97b5df217329bc319d62564a9f46ba11d7;p=l2e.git diff --git a/src/map/Map.h b/src/map/Map.h index 5eacc7b..101689f 100644 --- a/src/map/Map.h +++ b/src/map/Map.h @@ -1,51 +1,70 @@ -/* - * Map.h - * - * Created on: Sep 29, 2012 - * Author: holy - */ - #ifndef MAP_MAP_H_ #define MAP_MAP_H_ -#include "fwd.h" -#include "../geometry/Vector.h" -#include "../graphics/fwd.h" +namespace map { + class Area; + class Tile; + class Trigger; +} +namespace math { + template + class Vector; +} + +#include "Entity.h" #include namespace map { +/// Represents a single map in the game. +/// Maps are made up of uniform areas of tiles. +/// The looks of a tile is defined by the Tileset() sprite with Tile::Offset() +/// as the column and row in the sprite. +/// Maps can be propulated with triggers and entities. Those are or use with +/// MapState and are not handled by the map itself. +/// Positions are expressed either as pixel or tile coordinates depending on +/// function purpose with (0|0) being the top left corner and positive values +/// extending to the right and down respectively. class Map { +public: + static const int TYPE_ID = 602; + public: Map(); ~Map() { } public: + /// The sprite used as the tileset. const graphics::Sprite *Tileset() const { return tileset; } - Area *AreaAt(const geometry::Vector &); - const Area *AreaAt(const geometry::Vector &) const; - Tile *TileAt(const geometry::Vector &); - const Tile *TileAt(const geometry::Vector &) const; - Trigger *TriggerAt(const geometry::Vector &); - SDL_Surface *BattleBackgroundAt(const geometry::Vector &); - geometry::Vector TileCoordinates(const geometry::Vector &) const; + /// Returns the Area at given pixel coordinates or 0 if off the map. + Area *AreaAt(const math::Vector &); + const Area *AreaAt(const math::Vector &) const; + /// Returns the Tile at given pixel coordinates or 0 if off the map. + Tile *TileAt(const math::Vector &); + const Tile *TileAt(const math::Vector &) const; + /// Returns the Trigger at given pixel coordinates or 0 if off the map. + /// Multiple triggers are not supported. The first one found is returned. + Trigger *TriggerAt(const math::Vector &); + /// The battle background image for this map if neither the tile nor the + /// area has one specified. + SDL_Surface *BattleBackgroundAt(const math::Vector &); + /// Convert coordinates pixel to tile. + math::Vector TileCoordinates(const math::Vector &) const; - Entity **EntitiesBegin() { return &entities; } - Entity **EntitiesEnd() { return (&entities) + numEntities; } + Entity *EntitiesBegin() { return entities; } + Entity *EntitiesEnd() { return entities + numEntities; } - void Render(SDL_Surface *dest, const geometry::Vector &offset) const; - void RenderDebug(SDL_Surface *dest, const geometry::Vector &offset) const; + /// Render the map. + /// Entities are not rendered by this function. + void Render(SDL_Surface *dest, const math::Vector &offset) const; + /// Render a debugging overlay that includes collision and trigger + /// information. + void RenderDebug(SDL_Surface *dest, const math::Vector &offset) const; -// temporary setters -public: - void SetTileset(const graphics::Sprite *t) { tileset = t; } - void SetBattleBackground(SDL_Surface *bg) { battlebg = bg; } - void SetAreas(Area *a, int num) { areas = a; numAreas = num; } - void SetTriggers(Trigger *t, int num) { triggers = t; numTriggers = num; } - void SetEntities(Entity *e, int num) { entities = e; numEntities = num; } - void SetWidth(int w) { width = w; } + static void CreateTypeDescription(); + static void Construct(void *); private: const graphics::Sprite *tileset;