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 generated level goals

The final system that we're going to build in this chapter is one that will generate randomized level goals. In each level, we have to find the key, find the exit, and kill all enemies that get in our way. Let's add more gameplay and challenge by adding random goals that the player can also complete. Every time a level is entered, we'll potentially give the player an optional task that, if completed, will yield a random reward.

The variable and function declarations

The first step in creating this system is to declare the variables and functions that we're going to need. We'll encapsulate the behavior to generate a goal in its own function. For starters, we need to declare the following private function in Game.h ...

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