From a228846d35bda1fd6dcb121c32b56c481d6977d4 Mon Sep 17 00:00:00 2001 From: klangner Date: Sat, 17 Oct 2020 18:25:16 +0200 Subject: [PATCH] Fixed README example --- README.md | 32 +++++++++++++++++--------------- examples/example1.rs | 21 +++++++++++++++++++++ 2 files changed, 38 insertions(+), 15 deletions(-) create mode 100644 examples/example1.rs diff --git a/README.md b/README.md index c4bc2e4..1cc1766 100644 --- a/README.md +++ b/README.md @@ -41,31 +41,33 @@ Using single map generator: ```rust use rand::prelude::*; -use mapgen::dungeon::{ - MapGenerator, - cellular_automata::CellularAutomataGen -}; +use mapgen::{Map, MapFilter}; +use mapgen::filter::CellularAutomata; let mut rng = StdRng::seed_from_u64(100); -let gen = CellularAutomataGen::new(80, 50); -let map = gen.generate_map(&mut rng) +let gen = CellularAutomata::new(); +let map = gen.modify_map(&mut rng, &Map::new(80, 50)); ``` Use MapBuilder for chaining map generator and modifiers ```rust -use mapgen::dungeon::{ +use mapgen::{ MapBuilder, - map::{Map, Point, TileType}, - cellular_automata::CellularAutomataGen, - starting_point::{AreaStartingPosition, XStart, YStart}, - cull_unreachable::CullUnreachable, + filter::{ + NoiseGenerator, + CellularAutomata, + AreaStartingPosition, + XStart, + YStart, + }, }; -let map = MapBuilder::new(CellularAutomataGen::new(80, 50)) - .with(AreaStartingPosition::new(XStart::CENTER, YStart::CENTER)) - .with(CullUnreachable::new()) - .build_map(); +let map = MapBuilder::new(80, 50) + .with(NoiseGenerator::uniform()) + .with(CellularAutomata::new()) + .with(AreaStartingPosition::new(XStart::CENTER, YStart::CENTER)) + .build(); ``` For more information check the [doc](https://docs.rs/mapgen) diff --git a/examples/example1.rs b/examples/example1.rs new file mode 100644 index 0000000..6b9f3e3 --- /dev/null +++ b/examples/example1.rs @@ -0,0 +1,21 @@ +use mapgen::{ + MapBuilder, + filter::{ + NoiseGenerator, + CellularAutomata, + AreaStartingPosition, + XStart, + YStart, + }, +}; + + +fn main() { + let map = MapBuilder::new(80, 50) + .with(NoiseGenerator::uniform()) + .with(CellularAutomata::new()) + .with(AreaStartingPosition::new(XStart::CENTER, YStart::CENTER)) + .build(); + + println!("{:}", &map); +} \ No newline at end of file