Usually I'd assume game state is using something like a Finite State Machime (FSM).
https://gameprogrammingpatterns.com/state.html https://gamedevelopment.tutsplus.com/tutorials/finite-state-machines-theory-and-implementation--gamedev-11867For a game you could have states like:
- Title Screen
- Main menu
- Options menu
- Get Ready (show a message for a second or so)
- Playing
- Game Over (show a game over message for a few seconds)
The most simplistic way to handle that would be an enum for each state and a variable to hold the current state.
enum GameState
{
e_title,
e_mainMenu,
//etc...
};
GameState currentState;
Then during the game you'd run different logic and rendering code depending on the value in currentState.
A more advanced state system could use classes, stacks with history (to undo out of a state), etc.
FSMs can also be used deeper in the game, such as for AI, there could be a heap of different ones in one game.