Crates.io | here_be_dragons |
lib.rs | here_be_dragons |
version | 0.3.0 |
source | src |
created_at | 2022-03-18 19:39:38.986301 |
updated_at | 2023-02-22 16:48:28.973452 |
description | Map generator for games |
homepage | |
repository | https://labs.lightsout.games/projects/here_be_dragons |
max_upload_size | |
id | 552856 |
size | 97,136 |
Generate procedural maps for games.
This crate is based on mapgen.rs. Thanks to Krzysztof Langner for doing the hard work of implementing the many map generation algorithms this crate includes.
This library consists of different map filters which can be combined to create custom map generators.
Add the dependency to your project
here_be_dragons = "0.1"
Using single map generator:
use rand::prelude::*;
use here_be_dragons::{Map, MapFilter};
use here_be_dragons::filter::CellularAutomata;
let mut rng = StdRng::seed_from_u64(100);
let gen = CellularAutomata::new();
let map = gen.modify_map(&mut rng, &Map::new(80, 50));
Use MapBuilder for chaining map generator and modifiers
use here_be_dragons::{
MapBuilder,
filter::{
NoiseGenerator,
CellularAutomata,
AreaStartingPosition,
XStart,
YStart,
},
};
let map = MapBuilder::new(80, 50)
.with(NoiseGenerator::uniform())
.with(CellularAutomata::new())
.with(AreaStartingPosition::new(XStart::CENTER, YStart::CENTER))
.with(CullUnreachable::new())
.with(DistantExit::new())
.build();
For more information check the docs.
This library is based on the code from the Roguelike tutorial. I highly recommend it for learning how to write a Roguelike in Rust.
Licensed under either of
at your option.
Contributions
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.