Crates.io | mapgen |
lib.rs | mapgen |
version | 0.6.0 |
source | src |
created_at | 2020-08-31 10:08:02.374185 |
updated_at | 2022-12-19 08:13:06.361296 |
description | Map generator for games (dungeons, worlds etc.) |
homepage | https://github.com/klangner/mapgen.rs |
repository | https://github.com/klangner/mapgen.rs |
max_upload_size | |
id | 283000 |
size | 769,204 |
Generate procedural maps for games. Try it in the browser using WebAssembly.
This library consists of different map filters which can be combined to create custom map generator.
Area exit point
Area starting point
BSP Interior
BSP Rooms
Cellular automata
Cull unreachable areas
Diffusion-Limited Aggregation (DLA)
Drunkard's walk
Maze
Noise generator
Prefabs
Room corridors nearest
Simple rooms
Voronoi hive
Wave Function Collapse
Add dependency to your project
mapgen = "0.4"
Using single map generator:
use rand::prelude::*;
use mapgen::{Map, MapFilter};
use mapgen::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 mapgen::{
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 doc
This library is based on the code from the Roguelike tutorial. I highly recommend it for learning how to write 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.