Building an interactive menu
To get started, let’s see what the menu will look like to the player in its two possible states.
Figure 19.1: Two menu states
We can see the two possibilities in the previous image. On the left, the player is informed that they can press Esc to start or F1 to quit, and on the right, the player can see that they can press Esc to continue or F1 to quit. The reason for the subtle difference is that while the game is playing, they will also be able to pause by pressing Esc. When on either of the menu screens, F1 will always quit, but while the game is being played, F1 has no effect.
Coding the MenuUpdate class
Now, we will create a new class that will control our in-game menu. Create a new class called MenuUpdate
derived from Update
and a new class called MenuGraphics
derived from Graphics
.
Now, we can start coding. Add the following code to MenuUpdate.h
:
#pragma once
#include "Update.h"
#include "InputReceiver...