Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

A configurable and editable dungeon generator using Binary-Space Partitioning and hand-made rooms.

License

Notifications You must be signed in to change notification settings

LandOfTheRair/dungeon

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dungeon

A configurable and editable dungeon generator using Binary-Space Partitioning and hand-made rooms.

dungeon

Running

If you want to get the development mode running to generate dungeons or edit rooms:

yarn
yarn start

This will launch the development server (using express.js):

Edit

When using the edit mode you can create, edit, or remove the rooms that are used for generating dungeons. The current editing session is saved to the local storage which makes it possible to continue editing later on.

  • You can load a rooms.json file to start with.
  • You can save the current editing session to a rooms.json file inside the /src/generate/ folder to use it when generating dungeons.

Generate

When in the generate mode you can render dungeons by tuning some key parameters.

  • You can right click and save the generated image.
  • You can download a JSON representation of the dungeon.

Want to use the dungeon generation algorithm in you project?

You can copy the content of the /src/generate/ folder into your project and call it like so:

import { generate } from "./dungeon";

const dungeon = generate({
  mapWidth: 96, // Width of the dungeon in tiles
  mapHeight: 56, // Height of the dungeon in tiles
  mapGutterWidth: 1, // Gutter width of the dungeon
  iterations: 5, // Number of subdivision of the BSP tree
  containerSizeRatio: 0.45, // Minimum ratio of a container (under which it's retried)
  roomSpawnChance: 0.9, // Probability of a room being spawned
  corridorWidth: 2, // Width of the corridors joining containers
  corridorTrapChance: 0.5, // Probability of a trap spawning into a corridor
});

This will return:

{
    width: number;
    height: number;
    tree: TreeNode<Container>;
    layers: {
        tiles: TileMap;
        props: TileMap;
        monsters: TileMap;
    };
}

Assets

Thanks to @pixel_poem for the art package he published on Itch.io which made this game looks cool instantly.

Licenses

This project is under the MIT license.

About

A configurable and editable dungeon generator using Binary-Space Partitioning and hand-made rooms.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%