This commit is contained in:
Nolan Darilek 2022-03-18 11:56:34 -05:00
parent 20a14de05d
commit 1c29eb71cd
18 changed files with 53 additions and 57 deletions

View File

@ -1,13 +1,12 @@
[package] [package]
name = "mapgen" name = "here_be_dragons"
version = "0.5.2" version = "0.1.0"
authors = ["Krzysztof Langner <klangner@gmail.com>"] authors = ["Nolan Darilek <nolan@thewordnerd.info>", "Krzysztof Langner <klangner@gmail.com>"]
description = "Map generator for games (dungeons, worlds etc.)" description = "Map generator for games"
keywords = ["game", "map", "map-generator"] keywords = ["game", "map", "map-generator"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
repository = "https://github.com/klangner/mapgen.rs" repository = "https://labs.lightsout.games/projects/here_be_dragons"
homepage = "https://github.com/klangner/mapgen.rs" documentation = "https://docs.rs/here_be_dragons"
documentation = "https://docs.rs/mapgen"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,15 +1,17 @@
# Game Map Generator # Here Be Dragons
[![Build Status](https://travis-ci.org/klangner/mapgen.rs.svg?branch=master)](https://travis-ci.org/klangner/mapgen.rs) [![Crates.io](https://img.shields.io/crates/v/here_be_dragons.svg)](https://crates.io/crates/here_be_dragons)
[![Crates.io](https://img.shields.io/crates/v/mapgen.svg)](https://crates.io/crates/mapgen) [![here_be_dragons](https://docs.rs/here_be_dragons/badge.svg)](https://docs.rs/here_be_dragons/)
[![mapgen.rs](https://docs.rs/mapgen/badge.svg)](https://docs.rs/mapgen/)
Generate procedural maps for games. [Try it in the browser](https://klangner.github.io/mapgen.rs/) using WebAssembly. 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 ## Map filters
This library consists of different map filters which can be combined to create custom map generator. This library consists of different map filters which can be combined to create custom map generators.
### Implemented filters ### Implemented filters
@ -29,20 +31,19 @@ This library consists of different map filters which can be combined to create c
* [x] Voronoi hive * [x] Voronoi hive
* [ ] Wave Function Collapse * [ ] Wave Function Collapse
## Usage ## Usage
Add dependency to your project Add the dependency to your project
``` ```
mapgen = "0.4" here_be_dragons = "0.1"
``` ```
Using single map generator: Using single map generator:
```rust ```rust
use rand::prelude::*; use rand::prelude::*;
use mapgen::{Map, MapFilter}; use here_be_dragons::{Map, MapFilter};
use mapgen::filter::CellularAutomata; use here_be_dragons::filter::CellularAutomata;
let mut rng = StdRng::seed_from_u64(100); let mut rng = StdRng::seed_from_u64(100);
let gen = CellularAutomata::new(); let gen = CellularAutomata::new();
@ -52,7 +53,7 @@ let map = gen.modify_map(&mut rng, &Map::new(80, 50));
Use MapBuilder for chaining map generator and modifiers Use MapBuilder for chaining map generator and modifiers
```rust ```rust
use mapgen::{ use here_be_dragons::{
MapBuilder, MapBuilder,
filter::{ filter::{
NoiseGenerator, NoiseGenerator,
@ -72,14 +73,11 @@ let map = MapBuilder::new(80, 50)
.build(); .build();
``` ```
For more information check the [doc](https://docs.rs/mapgen) 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.
This library is based on the code from the [Roguelike tutorial](https://github.com/thebracket/rustrogueliketutorial). ## License
I highly recommend it for learning how to write Roguelike in Rust.
# License
Licensed under either of Licensed under either of
@ -88,9 +86,8 @@ Licensed under either of
at your option. at your option.
**Contributions** **Contributions**
Unless you explicitly state otherwise, any contribution intentionally submitted 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 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. dual licensed as above, without any additional terms or conditions.

View File

@ -1,4 +1,4 @@
use mapgen::*; use here_be_dragons::*;
use rand::prelude::*; use rand::prelude::*;
fn main() { fn main() {

View File

@ -1,4 +1,4 @@
use mapgen::*; use here_be_dragons::*;
use rand::prelude::*; use rand::prelude::*;
use std::time::{SystemTime, UNIX_EPOCH}; use std::time::{SystemTime, UNIX_EPOCH};

View File

@ -1,4 +1,4 @@
use mapgen::{ use here_be_dragons::{
filter::{ filter::{
AreaStartingPosition, CellularAutomata, CullUnreachable, NoiseGenerator, XStart, YStart, AreaStartingPosition, CellularAutomata, CullUnreachable, NoiseGenerator, XStart, YStart,
}, },
@ -16,8 +16,8 @@ impl MapFilter<MyData> for IncrementData {
fn modify_map( fn modify_map(
&self, &self,
_rng: &mut rand::prelude::StdRng, _rng: &mut rand::prelude::StdRng,
map: &mapgen::Map<MyData>, map: &here_be_dragons::Map<MyData>,
) -> mapgen::Map<MyData> { ) -> here_be_dragons::Map<MyData> {
let mut map = map.clone(); let mut map = map.clone();
map.data.value += 1; map.data.value += 1;
map map

View File

@ -1,4 +1,4 @@
use mapgen::{ use here_be_dragons::{
filter::{ filter::{
AreaStartingPosition, CellularAutomata, CullUnreachable, NoiseGenerator, XStart, YStart, AreaStartingPosition, CellularAutomata, CullUnreachable, NoiseGenerator, XStart, YStart,
}, },

View File

@ -9,7 +9,7 @@
//! --- //! ---
//! use rand::prelude::*; //! use rand::prelude::*;
//! use crate::common::geometry::Point; //! use crate::common::geometry::Point;
//! use mapgen::dungeon::{ //! use here_be_dragons::dungeon::{
//! MapModifier, //! MapModifier,
//! map::{Map, TileType}, //! map::{Map, TileType},
//! starting_point::{AreaStartingPosition, XStart, YStart} //! starting_point::{AreaStartingPosition, XStart, YStart}

View File

@ -6,8 +6,8 @@
//! Example generator usage: //! Example generator usage:
//! ``` //! ```
//! use rand::prelude::*; //! use rand::prelude::*;
//! use mapgen::{Map, MapFilter, NoData}; //! use here_be_dragons::{Map, MapFilter, NoData};
//! use mapgen::filter::{ //! use here_be_dragons::filter::{
//! BspInterior //! BspInterior
//! }; //! };
//! //!

View File

@ -6,8 +6,8 @@
//! Example generator usage: //! Example generator usage:
//! ``` //! ```
//! use rand::prelude::*; //! use rand::prelude::*;
//! use mapgen::{Map, MapFilter, NoData}; //! use here_be_dragons::{Map, MapFilter, NoData};
//! use mapgen::filter::BspRooms; //! use here_be_dragons::filter::BspRooms;
//! //!
//! let mut rng = StdRng::seed_from_u64(100); //! let mut rng = StdRng::seed_from_u64(100);
//! let gen = BspRooms::<NoData>::new(); //! let gen = BspRooms::<NoData>::new();

View File

@ -9,8 +9,8 @@
//! Example usage: //! Example usage:
//! ``` //! ```
//! use rand::prelude::*; //! use rand::prelude::*;
//! use mapgen::{Map, MapFilter, NoData}; //! use here_be_dragons::{Map, MapFilter, NoData};
//! use mapgen::filter::CellularAutomata; //! use here_be_dragons::filter::CellularAutomata;
//! //!
//! let mut rng = StdRng::seed_from_u64(100); //! let mut rng = StdRng::seed_from_u64(100);
//! let gen = CellularAutomata::<NoData>::new(); //! let gen = CellularAutomata::<NoData>::new();

View File

@ -1,8 +1,8 @@
//! Example generator usage: //! Example generator usage:
//! ``` //! ```
//! use rand::prelude::*; //! use rand::prelude::*;
//! use mapgen::{Map, MapFilter, NoData}; //! use here_be_dragons::{Map, MapFilter, NoData};
//! use mapgen::filter::DrunkardsWalk; //! use here_be_dragons::filter::DrunkardsWalk;
//! //!
//! let mut rng = StdRng::seed_from_u64(100); //! let mut rng = StdRng::seed_from_u64(100);
//! let gen = DrunkardsWalk::<NoData>::open_area(); //! let gen = DrunkardsWalk::<NoData>::open_area();

View File

@ -1,8 +1,8 @@
//! Example generator usage: //! Example generator usage:
//! ``` //! ```
//! use rand::prelude::*; //! use rand::prelude::*;
//! use mapgen::{Map, MapFilter, NoData}; //! use here_be_dragons::{Map, MapFilter, NoData};
//! use mapgen::filter::MazeBuilder; //! use here_be_dragons::filter::MazeBuilder;
//! //!
//! let mut rng = StdRng::seed_from_u64(100); //! let mut rng = StdRng::seed_from_u64(100);
//! let gen = MazeBuilder::<NoData>::new(); //! let gen = MazeBuilder::<NoData>::new();

View File

@ -4,8 +4,8 @@
//! Example usage: //! Example usage:
//! ``` //! ```
//! use rand::prelude::*; //! use rand::prelude::*;
//! use mapgen::{Map, MapFilter, NoData}; //! use here_be_dragons::{Map, MapFilter, NoData};
//! use mapgen::filter::NoiseGenerator; //! use here_be_dragons::filter::NoiseGenerator;
//! //!
//! let mut rng = StdRng::seed_from_u64(100); //! let mut rng = StdRng::seed_from_u64(100);
//! let gen = NoiseGenerator::<NoData>::uniform(); //! let gen = NoiseGenerator::<NoData>::uniform();

View File

@ -6,8 +6,8 @@
//! Example generator usage: //! Example generator usage:
//! ``` //! ```
//! use rand::prelude::*; //! use rand::prelude::*;
//! use mapgen::{MapFilter, Map, NoData}; //! use here_be_dragons::{MapFilter, Map, NoData};
//! use mapgen::filter::SimpleRooms; //! use here_be_dragons::filter::SimpleRooms;
//! //!
//! let mut rng = StdRng::seed_from_u64(100); //! let mut rng = StdRng::seed_from_u64(100);
//! let gen = SimpleRooms::<NoData>::new(); //! let gen = SimpleRooms::<NoData>::new();

View File

@ -6,9 +6,9 @@
//! Example modifier usage: //! Example modifier usage:
//! ``` //! ```
//! use rand::prelude::*; //! use rand::prelude::*;
//! use mapgen::{MapFilter, Map, NoData, Tile}; //! use here_be_dragons::{MapFilter, Map, NoData, Tile};
//! use mapgen::filter::starting_point::{AreaStartingPosition, XStart, YStart}; //! use here_be_dragons::filter::starting_point::{AreaStartingPosition, XStart, YStart};
//! use mapgen::geometry::Point; //! use here_be_dragons::geometry::Point;
//! //!
//! let mut rng = StdRng::seed_from_u64(100); //! let mut rng = StdRng::seed_from_u64(100);
//! let mut map = Map::<NoData>::new(80, 50); //! let mut map = Map::<NoData>::new(80, 50);

View File

@ -1,8 +1,8 @@
//! Example generator usage: //! Example generator usage:
//! ``` //! ```
//! use rand::prelude::*; //! use rand::prelude::*;
//! use mapgen::{Map, MapFilter, NoData}; //! use here_be_dragons::{Map, MapFilter, NoData};
//! use mapgen::filter::VoronoiHive; //! use here_be_dragons::filter::VoronoiHive;
//! //!
//! let mut rng = StdRng::seed_from_u64(100); //! let mut rng = StdRng::seed_from_u64(100);
//! let gen = VoronoiHive::<NoData>::new(); //! let gen = VoronoiHive::<NoData>::new();

View File

@ -84,7 +84,7 @@ impl Rect {
/// Calculate abs value between 2 usize values /// Calculate abs value between 2 usize values
/// Example: /// Example:
/// ``` /// ```
/// use mapgen::geometry::usize_abs; /// use here_be_dragons::geometry::usize_abs;
/// ///
/// assert_eq!(usize_abs(5, 3), 2); /// assert_eq!(usize_abs(5, 3), 2);
/// assert_eq!(usize_abs(3, 5), 2); /// assert_eq!(usize_abs(3, 5), 2);

View File

@ -8,13 +8,13 @@
//! //!
//! Example //! Example
//! ``` //! ```
//! use mapgen::{MapFilter, MapBuilder, Map, NoData, Tile}; //! use here_be_dragons::{MapFilter, MapBuilder, Map, NoData, Tile};
//! use mapgen::filter::{ //! use here_be_dragons::filter::{
//! NoiseGenerator, //! NoiseGenerator,
//! CellularAutomata, //! CellularAutomata,
//! starting_point::{AreaStartingPosition, XStart, YStart} //! starting_point::{AreaStartingPosition, XStart, YStart}
//! }; //! };
//! use mapgen::geometry::Point; //! use here_be_dragons::geometry::Point;
//! //!
//! let map = MapBuilder::<NoData>::new(80, 50) //! let map = MapBuilder::<NoData>::new(80, 50)
//! .with(NoiseGenerator::uniform()) //! .with(NoiseGenerator::uniform())