doryen-fov

Build Status Documentation crates.io

A pure rust library containing 2D field of view algorithms for roguelikes.

compilation instructions

native compilation

cargo run --example fov

web assembly compilation

rustup target install wasm32-unknown-unknown cargo install cargo-web cargo web start --example fov

usage

Cargo.toml : toml [dependency] doryen-fov="*"

main.rs : ```rust use doryen_fov::{FovAlgorithm, FovRecursiveShadowCasting, MapData};

fn main() { let mut fov = FovRecursiveShadowCasting::new(); let mapwidth = 10; let mapheight = 10; let mut map = MapData::new(mapwidth, mapheight); // build an empty map map.settransparent(5, 5, false); // put some wall let radius = 0; let playerx = 5; let playery = 6; map.clearfov(); // computefov does not clear the existing fov fov.computefov(&mut map, playerx, playery, radius, false); assert!(map.isinfov(5, 7)); } ```

contributions

You can contribute to this library through pull requests. If you do so, please update the CHANGELOG.md and CREDITS.md files. If you provide a new feature, consider adding an example as a tutorial/showcase.