13.3. Reading fov information
Checking if a cell is in fov
Once your computed the field of view, you can know if a cell is visible with :
bool TCODMap::isInFov(int x, int y) const
bool TCOD_map_is_in_fov(TCOD_map_t map, int x, int y)
map_is_in_fov(map, x, y)
bool TCODMap::isInFov(int x, int y)
Parameter | Description |
---|---|
map | In the C version, the map handler returned by the TCOD_map_new function. |
x,y | Coordinates of the cell we want to check. 0 <= x < map width. 0 <= y < map height. |
Example:
TCODMap *map = new TCODMap(50,50); // allocate the map
map->setProperties(10,10,true,true); // set a cell as 'empty'
map->computeFov(10,10); // calculate fov from the cell 10x10
bool visible=map->isInFov(10,10);
TCOD_map_t map = TCOD_map_new(50,50);
TCOD_map_set_properties(map,10,10,true,true);
TCOD_map_compute_fov(map,10,10);
bool visible = TCOD_map_is_in_fov(map,10,10);
map = libtcod.map_new(50,50)
libtcod.map_set_properties(map,10,10,True,True)
libtcod.map_compute_fov(map,10,10)
visible = libtcod.map_is_in_fov(map,10,10)
Checking a cell transparency/walkability
You can also retrieve transparent/walkable informations with :
bool TCODMap::isTransparent(int x, int y) const
bool TCODMap::isWalkable(int x, int y) const
bool TCOD_map_is_transparent(TCOD_map_t map, int x, int y)
bool TCOD_map_is_walkable(TCOD_map_t map, int x, int y)
map_is_transparent(map, x, y)
map_is_walkable(map, x, y)
bool TCODMap::isTransparent(int x, int y)
bool TCODMap::isWalkable(int x, int y)
Parameter | Description |
---|---|
map | In the C version, the map handler returned by the TCOD_map_new function. |
x,y | Coordinates of the cell we want to check. 0 <= x < map width. 0 <= y < map height. |
Getting the map size
You can retrieve the map size with :
int TCODMap::getWidth() const
int TCODMap::getHeight() const
int TCOD_map_get_width(TCOD_map_t map)
int TCOD_map_get_height(TCOD_map_t map)
map_get_width(map)
map_get_height(map)
int TCODMap::getWidth()
int TCODMap::getHeight()
Parameter | Description |
---|---|
map | In the C version, the map handler returned by the TCOD_map_new function. |