2020-08-31 09:45:59 +00:00
|
|
|
# Game Map Generator
|
|
|
|
|
|
|
|
[![Build Status](https://travis-ci.org/klangner/mapgen.rs.svg?branch=master)](https://travis-ci.org/klangner/mapgen.rs)
|
2020-08-31 09:58:00 +00:00
|
|
|
[![Crates.io](https://img.shields.io/crates/v/mapgen.svg)](https://crates.io/crates/mapgen)
|
|
|
|
[![mapgen.rs](https://docs.rs/mapgen/badge.svg)](https://docs.rs/mapgen/)
|
2020-08-31 09:45:59 +00:00
|
|
|
|
2020-09-13 12:49:41 +00:00
|
|
|
Generate procedural maps for games. [Try it in the browser](https://klangner.github.io/mapgen.rs/) using WebAssembly.
|
2020-09-01 12:46:31 +00:00
|
|
|
|
|
|
|
|
2020-09-23 08:31:13 +00:00
|
|
|
## Map filters
|
|
|
|
|
|
|
|
This library consists of different map filters which can be combined to create custom map generator.
|
|
|
|
|
|
|
|
### Implemented filters
|
|
|
|
|
|
|
|
* [x] Area exit point
|
|
|
|
* [x] Area starting point
|
|
|
|
* [x] BSP Interior
|
|
|
|
* [x] BSP Rooms
|
|
|
|
* [x] Cellular automata
|
|
|
|
* [x] Cull unreachable areas
|
|
|
|
* [ ] Diffusion-Limited Aggregation (DLA)
|
|
|
|
* [x] Drunkard's walk
|
|
|
|
* [ ] Maze
|
|
|
|
* [x] Noise generator
|
|
|
|
* [ ] Prefabs
|
|
|
|
* [x] Room corridors nearest
|
|
|
|
* [x] Simple rooms
|
|
|
|
* [ ] Voronoi hive
|
|
|
|
* [ ] Wave Function Collapse
|
2020-09-01 12:46:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
Add dependency to your project
|
|
|
|
```
|
2020-09-22 18:45:49 +00:00
|
|
|
mapgen = "0.3"
|
2020-09-01 12:46:31 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Using single map generator:
|
|
|
|
|
|
|
|
```rust
|
|
|
|
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)
|
|
|
|
```
|
|
|
|
|
2020-09-03 19:54:24 +00:00
|
|
|
Use MapBuilder for chaining map generator and modifiers
|
|
|
|
|
|
|
|
```rust
|
|
|
|
use mapgen::dungeon::{
|
|
|
|
MapBuilder,
|
|
|
|
map::{Map, Point, TileType},
|
|
|
|
cellular_automata::CellularAutomataGen,
|
|
|
|
starting_point::{AreaStartingPosition, XStart, YStart},
|
2020-09-04 10:47:46 +00:00
|
|
|
cull_unreachable::CullUnreachable,
|
2020-09-03 19:54:24 +00:00
|
|
|
};
|
|
|
|
|
2020-09-15 05:39:51 +00:00
|
|
|
let map = MapBuilder::new(CellularAutomataGen::new(80, 50))
|
2020-09-03 19:54:24 +00:00
|
|
|
.with(AreaStartingPosition::new(XStart::CENTER, YStart::CENTER))
|
2020-09-04 10:47:46 +00:00
|
|
|
.with(CullUnreachable::new())
|
2020-09-03 19:54:24 +00:00
|
|
|
.build_map();
|
|
|
|
```
|
|
|
|
|
2020-09-01 12:46:31 +00:00
|
|
|
For more information check the [doc](https://docs.rs/mapgen)
|
2020-08-31 09:45:59 +00:00
|
|
|
|
2020-09-13 11:26:36 +00:00
|
|
|
|
|
|
|
This library is based on the code from the [Roguelike tutorial](https://github.com/thebracket/rustrogueliketutorial).
|
|
|
|
I highly recommend it for learning how to write Roguelike in Rust.
|
|
|
|
|
|
|
|
|
2020-08-31 09:45:59 +00:00
|
|
|
# License
|
|
|
|
|
|
|
|
Licensed under either of
|
|
|
|
|
|
|
|
* [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
|
|
|
* [MIT license](http://opensource.org/licenses/MIT)
|
|
|
|
|
|
|
|
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
|
2020-09-13 12:49:41 +00:00
|
|
|
dual licensed as above, without any additional terms or conditions.
|