Screen states

Before we begin adding new screens to our game, we will need to create some screen states. We will do most of the management of these states from within the main.cpp file. Different screen states will require different input, will run different logic, and different render functions. We will manage all of this at the highest level of our code as functions called by our game loop. We will define a list of possible states from within the game.hpp file as an enumeration:

enum SCREEN_STATE {
START_SCREEN = 0,
PLAY_SCREEN = 1,
PLAY_TRANSITION = 2,
GAME_OVER_SCREEN = 3,
YOU_WIN_SCREEN = 4
};

You may notice that even though there will only be three different screens, we have a total of five different screen states. START_SCREEN and PLAY_SCREEN are the start screen and play screen respectively. The PLAY_TRANSITION state transitions the screens between START_SCREEN and PLAY_SCREEN by fading in the gameplay instead of having an abrupt switch to play. We will use two different states for our game over screen. These states are GAME_OVER_SCREEN and YOU_WIN_SCREEN. The only difference between these two states is the message that's displayed when the game is over.