January 2016
Intermediate to advanced
304 pages
6h 17m
English
Now that the player and enemies have been taken care of, let's turn our attention to items. We have a number of classes that can have their member variables assigned randomly. We'll set up the potion class the way we set up the humanoid class, where we created a number of distinct objects from a single class.
We'll start with the smallest classes, namely Heart and Gem. These are very simple classes that have a single variable that is currently hard-coded. Let's update this so that their values are randomly generated every time they are created. Since we want this to happen each time an object is created, we'll place it in the items' constructors.
In Gem::Gem, we'll make the following change:
// Set the ...
Read now
Unlock full access