First, you have to allocate a map of the same size as your dungeon.
C++ : TCODMap::TCODMap(int width, int height)
C : TCOD_map_t TCOD_map_new(int widht, int height)
Parameter | Description |
width,height | The size of the map (in map cells). |
Then, build your dungeon by defining which cells let the light pass (by default, all cells block the light) and which cells are walkable (by default, all cells are not-walkable).
C++ : void TCODMap::setProperties(int x, int y, bool isTransparent, bool isWalkable)
C : void TCOD_map_set_properties(TCOD_map_t map, int x, int y, bool is_transparent, bool is_walkable)
Parameter | Description |
map | In the C version, the map handler returned by the TCOD_map_new function. |
x,y | Coordinate of the cell that we want to update. |
isTransparent | If true, this cell will let the light pass else it will block the light. |
isWalkable | If true, creatures can walk true this cell (it is not a wall). |
You can clear an existing map (setting all cells as 'blocking') with :
C++ : void TCODMap::clear()
C : void TCOD_map_clear(TCOD_map_t map)
Parameter | Description |
map | In the C version, the map handler returned by the TCOD_map_new function. |
Example :
C++ : TCODMap *map = new TCODMap(50,50); // allocate the map
map->setProperties(10,10,true,true); // set a cell as 'empty'
map->clear(); // reset the map (all blocking cells)
C : TCOD_map_t map = TCOD_map_new(50,50);
TCOD_map_set_properties(map,10,10,true,true);
TCOD_map_clear(map);