#roguelike #console #field-of-view #fov

doryen-fov

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

1 unstable release

0.1.1 Jun 15, 2019
0.1.0 Jun 15, 2019

#1018 in Game dev

Download history 27/week @ 2023-10-16 29/week @ 2023-10-23 33/week @ 2023-10-30 24/week @ 2023-11-06 24/week @ 2023-11-13 29/week @ 2023-11-20 30/week @ 2023-11-27 39/week @ 2023-12-04 24/week @ 2023-12-11 25/week @ 2023-12-18 30/week @ 2023-12-25 15/week @ 2024-01-01 25/week @ 2024-01-08 20/week @ 2024-01-15 24/week @ 2024-01-22 22/week @ 2024-01-29

96 downloads per month
Used in 2 crates

MIT license

19KB
409 lines

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 :

[dependency]
doryen-fov="*"

main.rs :

use doryen_fov::{FovAlgorithm, FovRecursiveShadowCasting, MapData};

fn main() {
    let mut fov = FovRecursiveShadowCasting::new();
    let map_width = 10;
    let map_height = 10;
    let mut map = MapData::new(map_width, map_height); // build an empty map
    map.set_transparent(5, 5, false); // put some wall
    let radius = 0;
    let player_x = 5;
    let player_y = 6;
    map.clear_fov(); // compute_fov does not clear the existing fov
    fov.compute_fov(&mut map, player_x, player_y, radius, false);
    assert!(map.is_in_fov(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.

No runtime deps