tile2d
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
TileMap< TileType > Class Template Reference

Classes

class  Iterator
 Allows iteration of tiles with for loops/. More...
 

Public Member Functions

 TileMap (_CreateTileMap)
 Do not call directly, to construct a tileMap use createTileMap()
 
const PhysicsTilePropertiesgetPhysicsTileProperties (const glm::i32vec2 &tilePos) const
 Returns the physical properties of a tile located at tilePos.
 
TileProperties< TileType > & getTileProperties (const glm::i32vec2 &tilePos)
 Returns the properties of a tile located at tilePos.
 
void beginBulkInsert ()
 Used to speed up the insert of a large amount of tiles. To use for speed up, call before inserting a large amount of tiles. Once the wanted amount of tiles has been inserted, endBulkInsert() MUST be called.
 
void endBulkInsert ()
 Used to speed up the insert of a large amount of tiles. To use for speed up, call after inserting a large amount of tiles. Before the wanted amount of tiles has been inserted, beginBulkInsert() MUST be called.
 
void beginBulkErase ()
 Used to speed up the erasure of a large amount of tiles. To use for speed up, call before erasing a large amount of tiles. After the wanted amount of tiles has been inserted, endBulkErase() MUST be called.
 
void endBulkErase ()
 Used to speed up the erasure of a large amount of tiles. To use for speed up, call after erasing a large amount of tiles. Before the wanted amount of tiles has been inserted, beginBulkErase() MUST be called.
 
bool addTile (const glm::i32vec2 &pos, const TileProperties< TileType > &props, const PhysicsTileProperties &physicsProperties={})
 Adds a tile at pos with the properties of props and the physics properties set to physicsProperties. If a tile already exists in that position, no change will be made.
 
bool removeTile (const glm::i32vec2 &pos) noexcept
 Removes a tile at pos.
 
glm::u16vec2 getTileDimensions (const glm::i32vec2 &pos) const
 Returns the tile dimensions of the tile located at pos.
 
vec2 getRealTileDimensions (const glm::i32vec2 &pos) const
 Returns the REAL tile dimensions, meaning world dimensions, of the tile located at pos.
 
size_t count () const
 Returns the amount of tiles, including the sub-tiles of multi-tiles.
 
TileBody< TileType > & body ()
 Returns the rigid body attached to this tile map.
 
Iterator begin ()
 
Iterator end ()
 

Protected Member Functions

void setTileBody (TileBody< TileType > *body)
 

Protected Attributes

FlatMap< glm::i32vec2, TileProperties< TileType > > m_tiles
 
FlatMap< glm::i32vec2, PhysicsTilePropertiesm_physicsTiles
 

Friends

class TileBody< TileType >
 
template<class ATileType , class TileMapAllocator , class PhysicsWorld >
class CreateTileMap
 

Member Function Documentation

◆ addTile()

template<typename TileType >
bool TileMap< TileType >::addTile ( const glm::i32vec2 & pos,
const TileProperties< TileType > & props,
const PhysicsTileProperties & physicsProperties = {} )

Adds a tile at pos with the properties of props and the physics properties set to physicsProperties. If a tile already exists in that position, no change will be made.

Parameters
posThe position of the tile to add @pararm props The tile properties of the tile
physicsPropertiesThe physicsProperties of the tile.
Returns
True if the tile could be added.

◆ body()

template<typename TileType >
TileBody< TileType > & TileMap< TileType >::body ( )

Returns the rigid body attached to this tile map.

Returns
The rigid body attached to this tile map

◆ count()

template<typename TileType >
size_t TileMap< TileType >::count ( ) const
inline

Returns the amount of tiles, including the sub-tiles of multi-tiles.

Returns
The amount of tiles

◆ getPhysicsTileProperties()

template<typename TileType >
const PhysicsTileProperties & TileMap< TileType >::getPhysicsTileProperties ( const glm::i32vec2 & tilePos) const
inline

Returns the physical properties of a tile located at tilePos.

Parameters
tilePosThe position of some tile to get the physical properties of
Returns
The physical properties of a tile located at tilePos

◆ getRealTileDimensions()

template<typename TileType >
vec2 TileMap< TileType >::getRealTileDimensions ( const glm::i32vec2 & pos) const
inline

Returns the REAL tile dimensions, meaning world dimensions, of the tile located at pos.

The tile must exist before calling this function

Parameters
posThe position of the tile to get the dimensions of
Returns
The real tile dimensions

◆ getTileDimensions()

template<typename TileType >
glm::u16vec2 TileMap< TileType >::getTileDimensions ( const glm::i32vec2 & pos) const
inline

Returns the tile dimensions of the tile located at pos.

The tile must exist before calling this function

Parameters
posThe position of the tile to get the dimensions of
Returns
The tile dimensions

◆ getTileProperties()

template<typename TileType >
TileProperties< TileType > & TileMap< TileType >::getTileProperties ( const glm::i32vec2 & tilePos)
inline

Returns the properties of a tile located at tilePos.

Parameters
tilePosThe position of some tile to get the properties of
Returns
The reference properties of a tile located at tilePos

◆ removeTile()

template<typename TileType >
bool TileMap< TileType >::removeTile ( const glm::i32vec2 & pos)
noexcept

Removes a tile at pos.

Parameters
posThe position of the tile to remove
Returns
True if the tile could be removed.

◆ setTileBody()

template<typename TileType >
void TileMap< TileType >::setTileBody ( TileBody< TileType > * body)
inlineprotected

SHOULD only be called while the tile map is being created.


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