Lives and levels
Pygame challenges · Catch, step 4 of 4 · 25 XP
Dropping fruit costs nothing and the game never gets harder, so there is no way to lose.
Your task
Now Catch becomes a real game. You start with 3 lives. Each time a fruit lands in the basket or hits the ground, the game calls tally(score, lives, was_caught):
- a catch adds 1 to
score; - a miss takes 1 from
lives; - the level is 1, plus 1 more for every 5 points: 0 to 4 points is level 1, 5 to 9 is level 2, and so on;
- the game is over when
livesreaches 0.
Return four values as a tuple, (score, lives, level, over), where over is True or False.
The game uses the level to make fruit come more often and fall faster: its top speed is 2 + level. Catch 30 to win.
The function is at the top of the program, marked fix this. Press Run to play the game as it is, then Check when your function is ready.
What Check tests
| Call | Should give |
|---|---|
a catch adds a pointtally(0, 3, True) | (1, 3, 1, False) |
a miss costs a lifetally(2, 3, False) | (2, 2, 1, False) |
the fifth point is level 2tally(4, 3, True) | (5, 3, 2, False) |
12 points is level 3tally(11, 2, True) | (12, 2, 3, False) |
losing the last life ends the gametally(7, 1, False) | (7, 0, 2, True) |