Map generation for games
demo | ||
docs | ||
src | ||
.gitignore | ||
.travis.yml | ||
Cargo.toml | ||
LICENSE-APACHE | ||
LICENSE-MIT | ||
README.md |
Game Map Generator
Generate procedural maps for games. Try it in the browser using WebAssembly.
Map filters
This library consists of different map filters which can be combined to create custom map generator.
Implemented filters
- 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
Usage
Add dependency to your project
mapgen = "0.3"
Using single map generator:
use rand::prelude::*;
use mapgen::dungeon::{
MapGenerator,
cellular_automata::CellularAutomataGen
};
let mut rng = StdRng::seed_from_u64(100);
let gen = CellularAutomataGen::new(80, 50);
let map = gen.generate_map(&mut rng)
Use MapBuilder for chaining map generator and modifiers
use mapgen::dungeon::{
MapBuilder,
map::{Map, Point, TileType},
cellular_automata::CellularAutomataGen,
starting_point::{AreaStartingPosition, XStart, YStart},
cull_unreachable::CullUnreachable,
};
let map = MapBuilder::new(CellularAutomataGen::new(80, 50))
.with(AreaStartingPosition::new(XStart::CENTER, YStart::CENTER))
.with(CullUnreachable::new())
.build_map();
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.
License
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.