Designing victory and defeat conditions

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 Points System, we wrote the necessary scripts to keep track of cucumbers and Cucumber Beetles. We also ensured the HUD is continuously updated with those counts. It is important for the player to have a sense of how they are doing in the game. Beyond just points, the player will want to continually review how many cucumbers and Cucumber Beetles there are in the game. The player will also want to know how many Cucumber Man lives remain. 

In the next section, we will update our game so the number of lives are updated and the player's health bar is put into use. These will provide the player with much-needed visual components of the HUD during gameplay.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset