here_be_dragons/README.md

93 lines
2.5 KiB
Markdown
Raw Normal View History

2022-03-18 16:56:34 +00:00
# Here Be Dragons
2020-08-31 09:45:59 +00:00
2022-03-18 16:56:34 +00:00
[![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/)
2020-08-31 09:45:59 +00:00
2022-03-18 16:56:34 +00:00
Generate procedural maps for games.
2020-09-01 12:46:31 +00:00
2022-03-18 16:56:34 +00:00
## 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.
2020-09-01 12:46:31 +00:00
2020-09-23 08:31:13 +00:00
## Map filters
2022-03-18 16:56:34 +00:00
This library consists of different map filters which can be combined to create custom map generators.
2020-09-23 08:31:13 +00:00
### 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
2020-11-03 08:04:33 +00:00
* [x] Maze
2020-09-23 08:31:13 +00:00
* [x] Noise generator
* [ ] Prefabs
* [x] Room corridors nearest
* [x] Simple rooms
2020-11-19 19:53:34 +00:00
* [x] Voronoi hive
2020-09-23 08:31:13 +00:00
* [ ] Wave Function Collapse
2020-09-01 12:46:31 +00:00
## Usage
2022-03-18 16:56:34 +00:00
Add the dependency to your project
2020-09-01 12:46:31 +00:00
```
2022-03-18 16:56:34 +00:00
here_be_dragons = "0.1"
2020-09-01 12:46:31 +00:00
```
Using single map generator:
```rust
use rand::prelude::*;
2022-03-18 16:56:34 +00:00
use here_be_dragons::{Map, MapFilter};
use here_be_dragons::filter::CellularAutomata;
2020-09-01 12:46:31 +00:00
let mut rng = StdRng::seed_from_u64(100);
2020-10-17 16:25:16 +00:00
let gen = CellularAutomata::new();
let map = gen.modify_map(&mut rng, &Map::new(80, 50));
2020-09-01 12:46:31 +00:00
```
2020-09-03 19:54:24 +00:00
Use MapBuilder for chaining map generator and modifiers
```rust
2022-03-18 16:56:34 +00:00
use here_be_dragons::{
2020-09-03 19:54:24 +00:00
MapBuilder,
2020-10-17 16:25:16 +00:00
filter::{
NoiseGenerator,
CellularAutomata,
AreaStartingPosition,
XStart,
YStart,
},
2020-09-03 19:54:24 +00:00
};
2020-10-17 16:25:16 +00:00
let map = MapBuilder::new(80, 50)
.with(NoiseGenerator::uniform())
.with(CellularAutomata::new())
.with(AreaStartingPosition::new(XStart::CENTER, YStart::CENTER))
2020-11-03 08:24:33 +00:00
.with(CullUnreachable::new())
.with(DistantExit::new())
2020-10-17 16:25:16 +00:00
.build();
2020-09-03 19:54:24 +00:00
```
2022-03-18 16:56:34 +00:00
For more information check the [docs](https://docs.rs/here_be_dragons).
2020-09-13 11:26:36 +00:00
2022-03-18 16:56:34 +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 a Roguelike in Rust.
2020-09-13 11:26:36 +00:00
2022-03-18 16:56:34 +00:00
## License
2020-08-31 09:45:59 +00:00
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
2022-03-18 16:56:34 +00:00
dual licensed as above, without any additional terms or conditions.