Roguelike: BSP Dungeons
Build structured dungeon layouts with Binary Space Partitioning — recursively subdivide space, place rooms in leaves, and connect them with corridors.
No login required.
Partitioning Space
BSP recursively subdivides the map into leaves. You'll define the root partition, add a size guard to stop splitting, choose a split axis, and recurse into children.
Binary Space Partitioning guarantees non-overlapping rooms -- every room gets its own leaf, so dungeons look structured, not chaotic.
Loading game...
Click the game window to interact with it
What You'll Build
You will implement Binary Space Partitioning to generate structured dungeon layouts. The algorithm recursively splits a rectangular area into halves (alternating horizontal and vertical), places rooms inside the smallest partitions (leaves), and connects sibling rooms with corridors. The result is a dungeon with well-spaced rooms and guaranteed connectivity.
Learning Goals
- ✓Recursive subdivision of a 2D space into a binary tree
- ✓Leaf detection and room placement within partition bounds
- ✓Corridor connection between sibling partitions
- ✓Minimum size constraints to prevent degenerate splits
- ✓Resource-based configuration for partition parameters
GDScript Concepts in This Part
Tips
- ✨Stop subdividing when a partition is below a minimum size — this creates the leaves where rooms are placed.
- ✨Connect rooms by drawing a corridor from the center of one sibling's room to the center of the other.