Procedural content generators (PCG) are prevalent in roguelike and RPG games. This tutorial series will cover a basic dungeon generator algorithm. As with any algorithm, you can always expand and integrate it in any other game type, be it 2D or 3D projects.
In this tutorial we’ll generate rooms connected by horizontal and vertical corridors on a TileMap. In our first iteration we’ll create rectangular rooms and in the second phase we’ll expand on it to include organic rooms.
You are going to learn:
RandomNumberGenerator
class to generate random numbers from uniform distributionsThis chapter is implemented as three related demos in our public Procedural Generation repository. Here are some notes to help you navigate the associated files and folders:
Common
: this folder contains the tile set files we’ll use in this lesson.BasicDungeon/01.Rectangular/Rectangular.tscn
: this is the final version of the code after finishing the first lesson of this chapter.BasicDungeon/02.AndOrganic/AndOrganic.tscn
: this is the final version of the next iteration on the code from the second lesson.BasicDungeon/03.Bonus/Bonus.tscn
: implements the final version of this chapter’s code. In this third folder you’ll see that some scripts have different class_name
usages. Since we can’t have multiple class_name
declarations with the same name, we have appended BasicDungeon
to all identifiers in our version. Don’t let this confuse you when you compare codes.This tutorial is based on work from: