O'Reilly logo

Procedural Content Generation for C++ Game Development by Dale Green

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required