Managing game states
While we could certainly get very elaborate with our game state management system, we are going to take a simple approach. Our game will have three basic states as follows:
TitleScreen
Playing
GameOver
Our simple state system will progress through a loop of these three states, as illustrated in the following diagram:
The state cycle will be a simple loop between our three states, so from the title screen, we play the game. When someone wins, we display a game over message and then return to the TitleScreen.
In addition, while in the Playing state, we will track turns for each player, enabling and disabling interface components as appropriate depending on the currently active player.