|
< index < 12. Field of view toolkit < 12.1 Building the map |
===================================== | > 12.3 Reading fov information |
typedef enum { FOV_BASIC,
FOV_DIAMOND,
FOV_SHADOW,
FOV_PERMISSIVE_0,FOV_PERMISSIVE_1,FOV_PERMISSIVE_2,FOV_PERMISSIVE_3,
FOV_PERMISSIVE_4,FOV_PERMISSIVE_5,FOV_PERMISSIVE_6,FOV_PERMISSIVE_7,FOV_PERMISSIVE_8,
FOV_RESTRICTIVE,
NB_FOV_ALGORITHMS } TCOD_fov_algorithm_t;
C++ : void TCODMap::computeFov(int playerX,int playerY, int maxRadius=0,bool light_walls = true, TCOD_fov_algorithm_t algo = FOV_BASIC)
C : void TCOD_map_compute_fov(TCOD_map_t map, int player_x, int player_y, int max_radius, bool light_walls, TCOD_fov_algorithm_t algo)
Py : map_compute_fov(map, player_x, player_y, max_radius=0, light_walls=True, algo=FOV_BASIC )
FOV_BASIC : classic libtcod fov algorithm (ray casted from the player to all the cells on the submap perimeter)| Parameter | Description |
|---|---|
| map | In the C version, the map handler returned by the TCOD_map_new function. |
| player_x,player_y | Position of the player in the map. 0 <= player_x < map width. 0 <= player_y < map height. |
| maxRadius | If > 0, the fov is only computed up to maxRadius cells away from the player. Else, the range is unlimited. |
| light_walls | Wether the wall cells near ground cells in fov must be in fov too. |
| algo | FOV algorithm to use. |
C++ : 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 (basic raycasting, unlimited range, walls lighting on)
C : 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,0,true,FOV_SHADOW); // using shadow casting
Py : map = libtcod.map_new(50,50)
libtcod.map_set_properties(map,10,10,True,True)
libtcod.map_compute_fov(map,10,10,0,True,libtcod.FOV_PERMISSIVE(2))