The random potion class

For the biggest class update, we'll turn our attention to the potion class. This class currently has a fixed sprite and doesn't give the player anything. With the humanoid class, we can generate a random type and essentially create two different enemies from a single class. We're going to use this same approach for the potions.

Creating a random potion

To start, let's define an enumerator in Util.h that denotes all potion types. We'll create one for each stat, as follows:

// Potions.
enum class POTION {
  ATTACK,
  DEFENSE,
  STRENGTH,
  DEXTERITY,
  STAMINA,
  COUNT
};

To save a lot of typing, the potion class already has the member variables and the getter functions for each possible stat, we just need to use them. One thing that we ...

Get Procedural Content Generation for C++ Game Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.