#tile #portal #generator #size #dungeon #dungen #minion

yanked dungen_minion

A dungeon generator focused on 2D roguelikes

0.3.2 Sep 20, 2021
0.3.1 Sep 20, 2021
0.3.0 Oct 27, 2020
0.2.3 Oct 24, 2020
0.1.6 Oct 10, 2020

#24 in #dungeon

26 downloads per month

Custom license

65KB
807 lines

Usage

Advanced Usage

See the documentation for further details.

Basic Usage

// External includes.
use dungen_minion::geometry::*;
use dungen_minion::*;

// Standard includes.

// Internal includes.

fn main() {
    // Create a dungeon generator using RoomHashMap.
    // RoomHashMap is expandable, and has no explicit size restrictions.
    let dungen = DunGen::new(Box::new(RoomHashMap::default()))
        // Expand the room to a width of 40, and a height of 30.
        // TileType::Floor will be placed.
        .gen_with(EmptyRoomDunGen::new(Size::new(40, 30)))
        // Create walls for the room.
        .gen::<WalledRoomDunGen>()
        .build();
   
    // A simple drawing routine.
    for y in 0..dungen.size().height() {
        for x in 0..dungen.size().width() {
            let tile_type = dungen.tile_type_at_local(LocalPosition::new(x, y));
            if tile_type.is_none() {
                continue;
            }
   
            // The selection of tiles is deliberately limited, for now.
            // Theming is included in future plans for dungen_minion.
            let tile_type = tile_type.unwrap();
            let ch = match tile_type {
                TileType::Void => ' ',
                TileType::Floor => '.',
                TileType::Wall => '#',
                TileType::Portal => '+',
            };
   
            print!("{}", ch);
        }
        println!();
    }
}

Dependencies

~2.3–3.5MB
~63K SLoC