Skip to content

halftheopposite/graph-dungeon-generator

Folders and files

NameName
Last commit message
Last commit date
Jun 10, 2023
Feb 24, 2024
Mar 15, 2024
Mar 15, 2024
May 29, 2023
May 31, 2023
May 31, 2023
May 29, 2023
Jul 3, 2024
Jun 13, 2023
May 31, 2023

Repository files navigation

Graph Dungeon Generator


Hello fellow game developer πŸ§™β€β™‚οΈ!

I need less than 5 minutes of your precious time, feedback, and experience, to answer a few questions about multiplayer game development that will help me shape future projects. Survey is available at https://tally.so/r/w81Xr5 and requires no signup and no bs.


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