Currently, our game has no clear end and does not implement any reward for the player's actions. In this section, we will design our game's victory and defeat conditions so that there is a clear goal or way to win the game.
In Chapter 3, Designing the Game, we identified three end-of-game conditions: two ending in defeat for our Cucumber Man, and only one resulting in defeat for our Cucumber Beetles.
Here are the victory conditions for our game:
- The Cucumber Beetles win if:
- There are no cucumbers left in the game
- The Cucumber Man runs out of lives
- The Cucumber Man wins if:
- There are no Cucumber Beetles left in the game
These victory and defeat conditions are pretty simple, and there can only be one winner. If the Cucumber Beetles win, the Cucumber Man loses.
In order to implement these conditions, we need to track the following with our scripts:
- Number of cucumbers
- Number of Cucumber Beetles
- Number of Cucumber Man lives remaining
In Chapter 10, Scripting Our...