libtcod
Loading...
Searching...
No Matches
fov.h
Go to the documentation of this file.
1/* BSD 3-Clause License
2 *
3 * Copyright © 2008-2025, Jice and the libtcod contributors.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
15 *
16 * 3. Neither the name of the copyright holder nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
34#pragma once
35#ifndef TCOD_FOV_H_
36#define TCOD_FOV_H_
37
38#include <stdbool.h>
39#ifdef __cplusplus
40#include <memory>
41#endif // __cplusplus
42#include "config.h"
43#include "error.h"
44#include "fov_types.h"
45
46#ifdef __cplusplus
47extern "C" {
48#endif
52
55TCOD_PUBLIC TCOD_Map* TCOD_map_new(int width, int height);
61TCOD_PUBLIC void TCOD_map_clear(TCOD_Map* map, bool transparent, bool walkable);
67TCOD_PUBLIC TCOD_Error TCOD_map_copy(const TCOD_Map* __restrict source, TCOD_Map* __restrict dest);
71TCOD_PUBLIC void TCOD_map_set_properties(TCOD_Map* map, int x, int y, bool is_transparent, bool is_walkable);
75TCOD_PUBLIC void TCOD_map_delete(TCOD_Map* map);
97 TCOD_Map* __restrict map, int pov_x, int pov_y, int max_radius, bool light_walls, TCOD_fov_algorithm_t algo);
101TCOD_PUBLIC bool TCOD_map_is_in_fov(const TCOD_Map* map, int x, int y);
105TCOD_PUBLIC void TCOD_map_set_in_fov(TCOD_Map* map, int x, int y, bool fov);
109TCOD_PUBLIC bool TCOD_map_is_transparent(const TCOD_Map* map, int x, int y);
113TCOD_PUBLIC bool TCOD_map_is_walkable(TCOD_Map* map, int x, int y);
117TCOD_PUBLIC int TCOD_map_get_width(const TCOD_Map* map);
121TCOD_PUBLIC int TCOD_map_get_height(const TCOD_Map* map);
125TCOD_PUBLIC int TCOD_map_get_nb_cells(const TCOD_Map* map);
127#ifdef __cplusplus
128} // extern "C"
129#endif // __cplusplus
130#endif // TCOD_FOV_H_
Libtcod config header.
Error handling module.
TCOD_Error
An enum of libtcod error codes.
Definition error.h:48
Field-of-view types.
TCOD_Error TCOD_map_copy(const TCOD_Map *source, TCOD_Map *dest)
Clone map data from source to dest.
int TCOD_map_get_height(const TCOD_Map *map)
Return the height of map.
bool TCOD_map_is_transparent(const TCOD_Map *map, int x, int y)
Return true if this cell is transparent.
bool TCOD_map_is_in_fov(const TCOD_Map *map, int x, int y)
Return true if this cell was touched by the current field-of-view.
void TCOD_map_set_properties(TCOD_Map *map, int x, int y, bool is_transparent, bool is_walkable)
Change the properties of a single cell.
TCOD_Map * TCOD_map_new(int width, int height)
Return a new TCOD_Map with width and height.
int TCOD_map_get_nb_cells(const TCOD_Map *map)
Return the total number of cells in map.
TCOD_Error TCOD_map_compute_fov(TCOD_Map *map, int pov_x, int pov_y, int max_radius, bool light_walls, TCOD_fov_algorithm_t algo)
Calculate the field-of-view.
bool TCOD_map_is_walkable(TCOD_Map *map, int x, int y)
Return true if this cell is walkable.
void TCOD_map_clear(TCOD_Map *map, bool transparent, bool walkable)
Set all cell values on map to the given parameters.
TCOD_fov_algorithm_t
Definition fov_types.h:63
void TCOD_map_set_in_fov(TCOD_Map *map, int x, int y, bool fov)
Set the fov flag on a specific cell.
int TCOD_map_get_width(const TCOD_Map *map)
Return the width of map.
void TCOD_map_delete(TCOD_Map *map)
Free a TCOD_Map object.
Private map struct.
Definition fov_types.h:51