93 lines
2.5 KiB
Markdown
93 lines
2.5 KiB
Markdown
# Here Be Dragons
|
|
|
|
[![Crates.io](https://img.shields.io/crates/v/here_be_dragons.svg)](https://crates.io/crates/here_be_dragons)
|
|
[![here_be_dragons](https://docs.rs/here_be_dragons/badge.svg)](https://docs.rs/here_be_dragons/)
|
|
|
|
Generate procedural maps for games.
|
|
|
|
## Acknowledgments
|
|
|
|
This crate is based on [mapgen.rs](https://github.com/klangner/mapgen.rs). Thanks to Krzysztof Langner for doing the hard work of implementing the many map generation algorithms this crate includes.
|
|
|
|
## Map filters
|
|
|
|
This library consists of different map filters which can be combined to create custom map generators.
|
|
|
|
### 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
|
|
* [x] Maze
|
|
* [x] Noise generator
|
|
* [ ] Prefabs
|
|
* [x] Room corridors nearest
|
|
* [x] Simple rooms
|
|
* [x] Voronoi hive
|
|
* [ ] Wave Function Collapse
|
|
|
|
## Usage
|
|
|
|
Add the dependency to your project
|
|
```
|
|
here_be_dragons = "0.1"
|
|
```
|
|
|
|
Using single map generator:
|
|
|
|
```rust
|
|
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
|
|
|
|
```rust
|
|
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](https://docs.rs/here_be_dragons).
|
|
|
|
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 a Roguelike in Rust.
|
|
|
|
## 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
|
|
dual licensed as above, without any additional terms or conditions. |