1 /******************************
2 ** Tsunagari Tile Engine **
4 ** Copyright 2011 OmegaSDG **
5 ******************************/
13 #include <Gosu/Gosu.hpp>
14 #include <libxml/parser.h>
15 #include <libxml/tree.h>
27 This class is responsible for each map, or area in a Tsunagari World.
33 // when changing TileFlags, be sure to make updates to Area::splitTileFlags()
36 player_nowalk
= 0x0002,
38 player_event
= 0x0008,
43 enum TileEventTriggers
{
52 Stores info for an event attached to a tile.
55 TileEventTriggers trigger
;
56 std::string argv
; // Function name and arguments.
61 Some tiles can teleport you to a new area or a new position
71 Contains the properties shared by all tiles of a certain type.
72 E.g.: all grass tiles have the same graphic, and all wall tiles
76 std::vector
<Gosu::Image
*> graphics
;
77 bool animated
; // Is the tile animated?
78 double ani_speed
; // Speed of animation in hertz
79 std::vector
<TileEvent
> events
;
80 unsigned flags
; // bitflags for each option in TileFlags enum
86 Stores a tile, including its animation properties, and things
87 attached to it. This is later given to the Tile class
88 constructor through TileMatrix.
92 std::vector
<TileEvent
> events
;
93 unsigned flags
; // bitflags for each option in TileFlags enum
99 Area(Resourcer
* rc
, World
* world
, Entity
* player
, const std::string
& filename
);
107 void buttonDown(const Gosu::Button btn
);
113 bool needsRedraw() const;
115 coord_t
getDimensions() const;
116 Tile
* getTile(coord_t c
);
121 Stores info for a tileset, and global settings for tiles.
125 coord_t tiledim
; // Dimensions per tile
126 std::vector
<TileType
> defaults
; // Global tile properties
131 Stores info for the intro or main music files.
135 std::string filename
;
138 bool processDescriptor();
139 bool processMapProperties(xmlNode
* node
);
140 TileType
defaultTileType(const Gosu::Bitmap source
, coord_t tiledim
,
142 bool processTileset(xmlNode
* node
);
143 bool processTileType(xmlNode
* node
, Tileset
& ts
);
144 bool processLayer(xmlNode
* node
);
145 bool processLayerProperties(xmlNode
* node
);
146 bool processLayerData(xmlNode
* node
);
147 bool processObjectGroup(xmlNode
* node
);
148 bool processObjectGroupProperties(xmlNode
* node
, int* zpos
);
149 bool processObject(xmlNode
* node
, int zpos
);
150 unsigned splitTileFlags(const std::string strOfFlags
);
151 Door
* parseDoor(const std::string dest
);
153 Gosu::Transform
translateCoords();
159 const std::string descriptor
;
161 typedef std::vector
<Tile
*> row_t
;
162 typedef std::vector
<row_t
> grid_t
;
163 typedef std::vector
<grid_t
> tilematrix_t
;
165 /* All layers in the map must be in the range of [0, n]. There cannot be
173 std::vector
<Tileset
> tilesets
;
177 std::string onLoadEvents
;