Procedurally generating a dungeon
It's time to put this theory into practice and implement procedural dungeon generation in our game for real. We'll move the
Level class from loading its data from a text file to generating it at runtime, and we'll also cover the application of the correct sprites to the tiles in the random level.
As we identified, one way of approaching this is to generate a maze over the entire play area and then generate rooms to carve out some larger open areas. This method not only generates tighter, more intertwined levels, but also saves us the step of having to connect mazes to rooms, leaving us with just two steps to generate great levels:
Changing how we view the maze
Before we write any code, we're going to make a change ...