
Procedural Content Generation for C++ Game Development
By :

Perhaps the simplest of all data types is the humble bool. With only two states, true and false, it shouldn't be too hard to set randomly! When represented as integers, the two states have the following properties:
Given this, to randomly assign a bool we simply need to generate either the number 0 or 1.
In Chapter 1, An Introduction to Procedural Generation, we covered the generation of random numbers within a specific range. Well we're now going to put that to use. Using the std::rand()
function we will generate a number between 0 and 1:
std::rand() % 2;
Remember, std::rand()
generates a number between 0
and RAND_MAX
function. We then calculate the remainder of that result divided by 2. This leaves just the range 0 and 1.
A bool
does not have to be set with the true
or false
keyword. You can assign an integer to a bool
and its state will be determined by the integer's value...
Change the font size
Change margin width
Change background colour