Blinka Jump uses a "three strikes and you're out" game play rule, where you have three lives to use during your game. These lives are represented by heart sprites at the top of the screen. 

There is a function, called life(), that displays the heart sprites to represent game play lives. It references the variable life_count to display the correct number of heart sprites.

#  function to display the heart sprites for lives
def life():
    for _ in range(0, 3):
        life_grid[_, 0] = EMPTY
        for hearts in range(life_count):
            life_grid[hearts, 0] = HEART

#  lives at beginning of the game
life_count = 3

In the loop, the life() function runs to display the sprites and there is a check for when the life_count reaches 0, since that ends the game.

#  heart sprites are displayed to show life count
        life()

#  if no lives are left then the game ends
        if life_count is 0:
            game_over = True

The life_count decreases by one every time that Blinka collides with a Sparky. This is detected when one of the Sparkys' x location is 8 and Blinka is slithering. When this occurs, the built-in speaker plays two tones (specifically a tritone, which sounds menacing) and life_count is updated to show the decrease.

#  if a Sparky collides with Blinka while she is slithering...
for s in range(3):
  if sparky_x[s] == 8 and blinka_grid.y == 32:
    #  tone is played
    simpleio.tone(board.SPEAKER, 493.88, 0.05)
    simpleio.tone(board.SPEAKER, 349.23, 0.05)
    #  lose a life
    life_count = life_count - 1

This guide was first published on Jul 01, 2020. It was last updated on Mar 14, 2024.

This page (Game Lives) was last updated on Mar 08, 2024.

Text editor powered by tinymce.