Games as a whole, and individual objects or characters, can often be thought of (or modeled as) passing through different states or modes. Modeling states and changes of state (due to events or game conditions) is a very common way to manage the complexity of games and game components. In this recipe, we create a simple three-state game (game playing/game won/game lost) using a GameManager class. Buttons and a timer are provided to simulate the events that would allow a player to win or lose the game:
![](https://static.packt-cdn.com/products/9781788471909/graphics/assets/db3d658f-f2bb-45a7-b80a-21f607df37ec.png)