Mana
|
A tile map. More...
#include <map.h>
Classes | |
struct | ParticleEffectData |
Public Types | |
enum | BlockType { BLOCKTYPE_NONE = -1 , BLOCKTYPE_WALL , BLOCKTYPE_CHARACTER , BLOCKTYPE_MONSTER , NB_BLOCKTYPES } |
enum | BlockMask { BLOCKMASK_WALL = 0x80 , BLOCKMASK_CHARACTER = 0x01 , BLOCKMASK_MONSTER = 0x02 , BLOCKMASK_ALL = 0xFF } |
enum | DebugFlags { DEBUG_NONE = 0x0 , DEBUG_GRID = 0x1 , DEBUG_COLLISION_TILES = 0x2 , DEBUG_BEING_COLLISION_RADIUS = 0x4 , DEBUG_BEING_POSITION = 0x8 , DEBUG_BEING_PATH = 0x10 , DEBUG_MOUSE_PATH = 0x20 , DEBUG_BEING_IDS = 0x40 , DEBUG_SPECIAL1 = 0x80 , DEBUG_SPECIAL2 = 0x100 , DEBUG_SPECIAL3 = 0x200 } |
Public Member Functions | |
Map (int width, int height, int tileWidth, int tileHeight) | |
Constructor, taking map and tile size as parameters. | |
~Map () override | |
void | initializeAmbientLayers () |
Initialize ambient layers. | |
void | update (int dt) |
Updates animations. | |
void | draw (Graphics *graphics, int scrollX, int scrollY) |
Draws the map to the given graphics output. | |
void | drawCollision (Graphics *graphics, int scrollX, int scrollY, int debugFlags) const |
Visualizes collision layer for debugging. | |
void | addLayer (MapLayer *layer) |
Adds a layer to this map. | |
void | addTileset (Tileset *tileset) |
Adds a tileset to this map. | |
Tileset * | getTilesetWithGid (unsigned gid) const |
Finds the tile set that a tile with the given global id is part of. | |
MetaTile * | getMetaTile (int x, int y) const |
Get tile reference. | |
void | blockTile (int x, int y, BlockType type) |
Marks a tile as occupied. | |
bool | getWalk (int x, int y, unsigned char walkmask=BLOCKMASK_WALL) const |
Gets walkability for a tile with a blocking bitmask. | |
bool | occupied (int x, int y) const |
Tells whether a tile is occupied by a being. | |
int | getWidth () const |
Returns the width of this map in tiles. | |
int | getHeight () const |
Returns the height of this map in tiles. | |
int | getTileWidth () const |
Returns the tile width of this map. | |
int | getTileHeight () const |
Returns the tile height used by this map. | |
Vector | getTileCenter (int x, int y) const |
Returns the tile center position in pixel coordinates. | |
std::string | getMusicFile () const |
std::string | getName () const |
std::string | getFilename () const |
Gives the map id based on filepath (ex: 009-1) | |
Position | checkNodeOffsets (int radius, unsigned char walkMask, const Position &position) const |
Check the current position against surrounding blocking tiles, and correct the position offset within tile when needed. | |
Position | checkNodeOffsets (int radius, unsigned char walkMask, int x, int y) const |
Path | findTilePath (int startPixelX, int startPixelY, int endPixelX, int endPixelY, unsigned char walkMask, int maxCost=20) |
Find a tile-centered path in pixel coordinates from one location to the next. | |
Path | findPixelPath (int startPixelX, int startPixelY, int destPixelX, int destPixelY, int radius, unsigned char walkmask, int maxCost=20) |
Find a pixel path from one location to the next using free offsets. | |
void | addParticleEffect (const std::string &effectFile, int x, int y, int w=0, int h=0) |
Adds a particle effect. | |
void | initializeParticleEffects (Particle *particleEngine) |
Initializes all added particle effects. | |
void | addAnimation (int gid, TileAnimation animation) |
Adds a tile animation to the map. | |
void | setDebugFlags (int flags) |
int | getDebugFlags () const |
TileAnimation * | getAnimationForGid (int gid) |
Gets the tile animation for a specific gid. | |
void | setMask (int mask) |
![]() | |
virtual | ~Properties ()=default |
std::string | getProperty (const std::string &name, const std::string &def=std::string()) const |
Get a map property. | |
float | getFloatProperty (const std::string &name, float def=0.0f) const |
Gets a map property as a float. | |
float | getIntProperty (const std::string &name, int def=0) const |
Gets a map property as an int. | |
bool | getBoolProperty (const std::string &name, bool def=false) const |
Gets a map property as a boolean. | |
bool | hasProperty (const std::string &name) const |
Returns whether a certain property is available. | |
void | setProperty (const std::string &name, const std::string &value) |
Set a map property. | |
Protected Member Functions | |
Actors::iterator | addActor (Actor *actor) |
Adds an actor to the map. | |
void | removeActor (Actors::iterator iterator) |
Removes an actor from the map. | |
Private Types | |
enum | LayerType { FOREGROUND_LAYERS , BACKGROUND_LAYERS } |
Private Member Functions | |
Path | findPath (int startX, int startY, int destX, int destY, unsigned char walkmask, int maxCost=20) |
Find a path from one location to the next in tile coordinates. | |
void | updateAmbientLayers (float scrollX, float scrollY) |
Updates scrolling of ambient layers. | |
void | drawAmbientLayers (Graphics *graphics, LayerType type, float scrollX, float scrollY, int detail) |
Draws the foreground or background layers to the given graphics output. | |
bool | contains (int x, int y) const |
Tells whether the given coordinates fall within the map boundaries. | |
Private Attributes | |
unsigned * | mOccupation [NB_BLOCKTYPES] |
Blockmasks for different entities. | |
int | mWidth |
int | mHeight |
int | mTileWidth |
int | mTileHeight |
int | mMaxTileHeight |
int | mMaxTileWidth |
MetaTile * | mMetaTiles |
std::vector< MapLayer * > | mLayers |
std::vector< Tileset * > | mTilesets |
Actors | mActors |
int | mDebugFlags |
unsigned | mOnClosedList |
unsigned | mOnOpenList |
std::vector< AmbientLayer > | mBackgrounds |
std::vector< AmbientLayer > | mForegrounds |
float | mLastScrollX |
float | mLastScrollY |
std::list< ParticleEffectData > | particleEffects |
std::map< int, TileAnimation > | mTileAnimations |
int | mMask = 1 |
Friends | |
class | Actor |
enum Map::BlockMask |
enum Map::BlockType |
enum Map::DebugFlags |
|
private |
Map::Map | ( | int | width, |
int | height, | ||
int | tileWidth, | ||
int | tileHeight | ||
) |
|
protected |
void Map::addAnimation | ( | int | gid, |
TileAnimation | animation | ||
) |
void Map::addLayer | ( | MapLayer * | layer | ) |
void Map::addParticleEffect | ( | const std::string & | effectFile, |
int | x, | ||
int | y, | ||
int | w = 0 , |
||
int | h = 0 |
||
) |
void Map::addTileset | ( | Tileset * | tileset | ) |
void Map::blockTile | ( | int | x, |
int | y, | ||
BlockType | type | ||
) |
|
inline |
|
private |
void Map::draw | ( | Graphics * | graphics, |
int | scrollX, | ||
int | scrollY | ||
) |
Draws the map to the given graphics output.
This method draws all layers, actors and overlay effects.
TODO: For efficiency reasons, this method could take into account the clipping rectangle set on the Graphics object. However, currently the map is always drawn full-screen.
void Map::drawCollision | ( | Graphics * | graphics, |
int | scrollX, | ||
int | scrollY, | ||
int | debugFlags | ||
) | const |
|
private |
Path Map::findPixelPath | ( | int | startPixelX, |
int | startPixelY, | ||
int | destPixelX, | ||
int | destPixelY, | ||
int | radius, | ||
unsigned char | walkmask, | ||
int | maxCost = 20 |
||
) |
Path Map::findTilePath | ( | int | startPixelX, |
int | startPixelY, | ||
int | endPixelX, | ||
int | endPixelY, | ||
unsigned char | walkMask, | ||
int | maxCost = 20 |
||
) |
TileAnimation * Map::getAnimationForGid | ( | int | gid | ) |
std::string Map::getFilename | ( | ) | const |
|
inline |
MetaTile * Map::getMetaTile | ( | int | x, |
int | y | ||
) | const |
Vector Map::getTileCenter | ( | int | x, |
int | y | ||
) | const |
|
inline |
Tileset * Map::getTilesetWithGid | ( | unsigned | gid | ) | const |
|
inline |
bool Map::getWalk | ( | int | x, |
int | y, | ||
unsigned char | walkmask = BLOCKMASK_WALL |
||
) | const |
|
inline |
void Map::initializeAmbientLayers | ( | ) |
void Map::initializeParticleEffects | ( | Particle * | particleEngine | ) |
bool Map::occupied | ( | int | x, |
int | y | ||
) | const |
|
protected |
void Map::update | ( | int | dt | ) |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |