Crate mapgen

source ·
Expand description

Generators for dungeon type maps.

Generators can bu used directly or they can be combined with MapGenerators and MapModifiers

  • MapGenerators are use to create initial map.
  • MapModifiers modify existing map.

Example

use mapgen::{MapFilter, MapBuilder};
use mapgen::filter::{
    NoiseGenerator,
    CellularAutomata,
    starting_point::{AreaStartingPosition, XStart, YStart}
};
use mapgen::geometry::Point;
 
let map = MapBuilder::new(80, 50)
            .with(NoiseGenerator::uniform())
            .with(CellularAutomata::new())
            .with(AreaStartingPosition::new(XStart::CENTER, YStart::CENTER))
            .build();
 
assert_eq!(map.width, 80);
assert_eq!(map.height, 50);
assert_eq!(map.starting_point.is_some(), true);

Re-exports

pub use map_buffer::MapBuffer;
pub use map_buffer::Symmetry;
pub use filter::*;

Modules

Generators for dungeon type maps.
Support function for 2D geometry
MapInfo structure contains information about elements of the map. Those elements are used by MapFilters to generate map in several steps. E.g. Most MapFilters will only update few MapInfo elements (like which cell is walkable) and some other will depend on provided data (like adding exit point)
Different metrics for the map Can be used to meausre the quality of the map or the quality of the generator. To meause the quality of the generator; generate lots of maps, measure them and the provide generator score as an average.

Structs

Used to chain MapBuilder and MapModifiers to create the final map.

Traits

Trait which should be implemented by map modifier. Modifier takes initiall map and apply changes to it.