Crate adam_fov_rs
source · [−]Expand description
An implementation of Adam Millazo’s FOV algorithm
To use it you must implement the VisibilityMap trait on your map type, or use the build in VisibilityMap2d. Then you can call fov::compute with your map which will populate visible tiles based on the map’s opaque tiles.
Example
use adam_fov_rs::*;
// Create a 50x50 visibility map
let mut map = VisibilityMap2d::default([50,50]);
// Set the tile at (15,15) to opaque
map[[15,15]].opaque = true;
// Compute our visible tiles and add them to the map
fov::compute([15,14], 5, &mut map);
// The space directly above our opaque tile is not visible
assert!(map[[15,16]].visible == false);
Taken from the terminal example
Modules
Module containing the compute function.
Structs
A 2-dimensional vector.
Traits
A trait for types representing an integer point on a 2d grid.
A trait used by the fov algorithm to calculate the resulting fov.