Dark theme

So, hopefully that makes things a bit simpiler. We'll look at making things even easier to construct in the next part. For now, let's talk about monsters.

At the end of the last part, we left our game with a number of options like this...

    decision = input("You come to a junction. Turn left or right [L,R]: ")
    if decision == "L" or decision == "l":
        print("You turn left and see a terrible ogre!")

But what is an ogre to do? Fight! That's what. But to fight, you need something to lose. Let's give our player some player_strength points. The player_strength will control how well they fight, but also they'll lose player_strength if they lose the fight. When they get to zero player_strength, they die. Let's give them 3 player_strength points to start with.

At the top of your file, after the import statement, add the following code to set up a variable called player_strength:

player_strength = 3

It's usual to add the main variables at the top of a program so they are easy to find.

Also add in another two import statements at the top of the file for a libraries we'll use later:

import random
import time

Now let's look at the fight...

[Home > Part 2 > Next]