Map Class Reference

#include <map.h>

Inheritance diagram for Map:

Properties

List of all members.


Detailed Description

A tile map.

Definition at line 143 of file map.h.


Public Types

enum  BlockType {
  BLOCKTYPE_NONE = -1, BLOCKTYPE_WALL, BLOCKTYPE_CHARACTER, BLOCKTYPE_MONSTER,
  NB_BLOCKTYPES
}

Public Member Functions

 Map (int width, int height, int tileWidth, int tileHeight)
 Constructor, taking map and tile size as parameters.
 ~Map ()
 Destructor.
void initializeOverlays ()
 Initialize map overlays.
void update (int ticks=1)
 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)
 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.
TilesetgetTilesetWithGid (int gid) const
 Finds the tile set that a tile with the given global id is part of.
MetaTilegetMetaTile (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, char walkmask=BLOCKMASK_WALL) const
 Gets walkability for a tile with a blocking bitmask.
int getWidth () const
 Returns the width of this map.
int getHeight () const
 Returns the height of this map.
int getTileWidth () const
 Returns the tile width of this map.
int getTileHeight () const
 Returns the tile height used by this map.
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.
SpriteIterator addSprite (Sprite *sprite)
 Adds a sprite to the map.
void removeSprite (SpriteIterator iterator)
 Removes a sprite from the map.
void addParticleEffect (const std::string &effectFile, int x, int y)
 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.
TileAnimationgetAnimationForGid (int gid)
 Gets the tile animation for a specific gid.

Private Member Functions

void drawOverlay (Graphics *graphics, float scrollX, float scrollY, int detail)
 Draws the overlay graphic to the given graphics output.
bool contains (int x, int y) const
 Tells whether the given coordinates fall within the map boundaries.

Private Attributes

int * mOccupation [NB_BLOCKTYPES]
int mWidth
int mHeight
int mTileWidth
int mTileHeight
int mMaxTileHeight
MetaTilemMetaTiles
Layers mLayers
Tilesets mTilesets
Sprites mSprites
int mOnClosedList
int mOnOpenList
std::list< AmbientOverlay * > mOverlays
float mLastScrollX
float mLastScrollY
std::list< ParticleEffectDataparticleEffects
std::map< int, TileAnimation * > mTileAnimations

Static Private Attributes

static const unsigned char BLOCKMASK_WALL = 0x80
 Blockmasks for different entities.
static const unsigned char BLOCKMASK_CHARACTER = 0x01
static const unsigned char BLOCKMASK_MONSTER = 0x02

Classes

struct  ParticleEffectData

Member Enumeration Documentation

Enumerator:
BLOCKTYPE_NONE 
BLOCKTYPE_WALL 
BLOCKTYPE_CHARACTER 
BLOCKTYPE_MONSTER 
NB_BLOCKTYPES 

Definition at line 146 of file map.h.


Constructor & Destructor Documentation

Map::Map ( int  width,
int  height,
int  tileWidth,
int  tileHeight 
)

Constructor, taking map and tile size as parameters.

Definition at line 176 of file map.cpp.

Map::~Map (  ) 

Destructor.

Definition at line 193 of file map.cpp.


Member Function Documentation

void Map::initializeOverlays (  ) 

Initialize map overlays.

Should be called after all the properties are set.

Definition at line 207 of file map.cpp.

void Map::update ( int  ticks = 1  ) 

Updates animations.

Called as needed.

Definition at line 251 of file map.cpp.

void Map::draw ( Graphics graphics,
int  scrollX,
int  scrollY 
)

Draws the map to the given graphics output.

This method draws all layers, sprites 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.

Definition at line 262 of file map.cpp.

void Map::drawCollision ( Graphics graphics,
int  scrollX,
int  scrollY 
)

Visualizes collision layer for debugging.

Definition at line 291 of file map.cpp.

void Map::addLayer ( MapLayer layer  ) 

Adds a layer to this map.

The map takes ownership of the layer.

Definition at line 233 of file map.cpp.

void Map::addTileset ( Tileset tileset  ) 

Adds a tileset to this map.

The map takes ownership of the tileset.

Definition at line 238 of file map.cpp.

Tileset * Map::getTilesetWithGid ( int  gid  )  const

Finds the tile set that a tile with the given global id is part of.

Definition at line 395 of file map.cpp.

MetaTile * Map::getMetaTile ( int  x,
int  y 
) const

Get tile reference.

Definition at line 447 of file map.cpp.

void Map::blockTile ( int  x,
int  y,
BlockType  type 
)

Marks a tile as occupied.

Definition at line 405 of file map.cpp.

bool Map::getWalk ( int  x,
int  y,
char  walkmask = BLOCKMASK_WALL 
) const

Gets walkability for a tile with a blocking bitmask.

When called without walkmask, only blocks against colliding tiles.

Definition at line 432 of file map.cpp.

int Map::getWidth ( void   )  const [inline]

Returns the width of this map.

Definition at line 225 of file map.h.

int Map::getHeight ( void   )  const [inline]

Returns the height of this map.

Definition at line 230 of file map.h.

int Map::getTileWidth (  )  const [inline]

Returns the tile width of this map.

Definition at line 235 of file map.h.

int Map::getTileHeight (  )  const [inline]

Returns the tile height used by this map.

Definition at line 240 of file map.h.

Path Map::findPath ( int  startX,
int  startY,
int  destX,
int  destY,
unsigned char  walkmask,
int  maxCost = 20 
)

Find a path from one location to the next.

Definition at line 465 of file map.cpp.

SpriteIterator Map::addSprite ( Sprite sprite  ) 

Adds a sprite to the map.

Definition at line 452 of file map.cpp.

void Map::removeSprite ( SpriteIterator  iterator  ) 

Removes a sprite from the map.

Definition at line 458 of file map.cpp.

void Map::addParticleEffect ( const std::string &  effectFile,
int  x,
int  y 
)

Adds a particle effect.

Definition at line 649 of file map.cpp.

void Map::initializeParticleEffects ( Particle particleEngine  ) 

Initializes all added particle effects.

Definition at line 658 of file map.cpp.

void Map::addAnimation ( int  gid,
TileAnimation animation 
) [inline]

Adds a tile animation to the map.

Definition at line 271 of file map.h.

TileAnimation * Map::getAnimationForGid ( int  gid  ) 

Gets the tile animation for a specific gid.

Definition at line 672 of file map.cpp.

void Map::drawOverlay ( Graphics graphics,
float  scrollX,
float  scrollY,
int  detail 
) [private]

Draws the overlay graphic to the given graphics output.

Definition at line 344 of file map.cpp.

bool Map::contains ( int  x,
int  y 
) const [private]

Tells whether the given coordinates fall within the map boundaries.

Definition at line 442 of file map.cpp.


Member Data Documentation

const unsigned char Map::BLOCKMASK_WALL = 0x80 [static, private]

Blockmasks for different entities.

Definition at line 294 of file map.h.

const unsigned char Map::BLOCKMASK_CHARACTER = 0x01 [static, private]

Definition at line 295 of file map.h.

const unsigned char Map::BLOCKMASK_MONSTER = 0x02 [static, private]

Definition at line 296 of file map.h.

int* Map::mOccupation[NB_BLOCKTYPES] [private]

Definition at line 297 of file map.h.

int Map::mWidth [private]

Definition at line 299 of file map.h.

int Map::mHeight [private]

Definition at line 299 of file map.h.

int Map::mTileWidth [private]

Definition at line 300 of file map.h.

int Map::mTileHeight [private]

Definition at line 300 of file map.h.

int Map::mMaxTileHeight [private]

Definition at line 301 of file map.h.

Definition at line 302 of file map.h.

Layers Map::mLayers [private]

Definition at line 303 of file map.h.

Definition at line 304 of file map.h.

Definition at line 305 of file map.h.

int Map::mOnClosedList [private]

Definition at line 308 of file map.h.

int Map::mOnOpenList [private]

Definition at line 308 of file map.h.

std::list<AmbientOverlay*> Map::mOverlays [private]

Definition at line 311 of file map.h.

float Map::mLastScrollX [private]

Definition at line 312 of file map.h.

float Map::mLastScrollY [private]

Definition at line 313 of file map.h.

Definition at line 322 of file map.h.

std::map<int, TileAnimation*> Map::mTileAnimations [private]

Definition at line 324 of file map.h.


The documentation for this class was generated from the following files:

Generated on Sun Apr 26 17:30:43 2009 for The Mana World by  doxygen 1.5.5