Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

halftheopposite/graph-dungeon-generator

Repository files navigation

Graph Dungeon Generator

A simple graph-based procedural dungeon generator.

Want to play with the generator? Try the demo here and have some fun πŸ§™β€β™‚οΈ.

Running the project πŸš€

  1. Clone the repository.
  2. Run yarn to install dependencies.
  3. Run yarn dev to build and run the project and listen for changes.
  4. Finally, double-click the public/index.html file to open the generator in your browser.

Examples

Given the same input graph, we can generate many dungeon shapes and pattern.

Architecture

The project is split into 3 distinct modules (aka folders) in an effort to separate concerns:

  • /generate: where all the generation code lies (returns an Node<Room> tree).
  • /draw: where we take the Node<Room> tree, generate a tilesmap, and render it to an HTML canvas with some debugging information.
  • /graphs: the list of input files used to generate the dungeon. Currently written in TypeScript for type safety, but could as well be JSON files.

What can it do? πŸ‘

  • Generate a dungeon given a non-circular graph
  • Backtracking when it cannot find a suitable spot for a child node
  • Elegantly place the corridors between rooms
  • Transform a node tree into a tilesmap
  • Render contextual information for convenience
  • Easily modifiable to add new room types and colors

What can't it do? πŸ‘Ž

This generator does not handle overly complex situations such as:

  • Nodes with too many children
  • L-shaped corridors
  • Circular nodes (ex: A β†’ B β†’ C β†’ A)

Roadmap πŸ—ΊοΈ

  • Prevent rooms from touching sides which doesn't respect graph constraints
  • Pick from a set of predefined rooms that are rectangles

About

A simple graph-based procedural dungeon generator.

Topics

Resources

License

Stars

Watchers

Forks

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /