Step 4: Three Lives β€οΈ
Games get exciting when you can lose. Let's add lives! β€οΈβ€οΈβ€οΈ
It's the score trick from the quiz show, running backwards:
lives = 3 # at the very top
lives = lives - 1 # ouch, that hurt
print(f"π Lives left: {lives}")
And then, after something bad happens, check if it's over:
if lives == 0:
print("π GAME OVER. The mansion keeps you forever.")
Suddenly every choice has weight. Walk into the cobwebs? That's a life. Poke the ghost? That's a life. π¬
Pro tip: put a lives check near the end of your program, so no matter which path they took, the game can declare game over.
Your mission
Keep your story and add:
lives = 3at the top- At least two bad choices that do
lives = lives - 1 - Tell them how many lives are left after each one
- A
if lives == 0:game-over message near the end
Be mean. It's more fun that way. π
Your code
Press βΆ Run to see what your code does!