Dark theme

If you got that working, great! Your code is probably getting quite long and complicated now. Here's ours:

import sys
import random
import time

name = "YourName"
print("---Welcome to the game " + name + "---")

print("After many days wandering the forest, you come across " +
"the entrance to what looks like a cave or mine - " +
"can this be what you are looking for?")
print("You've been told the golden crown lies in the depths " +
"of the old mines, guarded by a terrible beast.")

decision = input("Do you want to enter? [Y,N]: ")
if decision == "N" or decision == "n":
    print("Your quest is at an end, goodbye!")
    sys.exit()
elif decision == "Y" or decision == "y":
    print("You enter the mines.")
    print("The way is lit by candles on the wall.")
    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!")

        ogre_strength = 2
        while player_strength > 0 and ogre_strength > 0:
            print("You FIGHT!")
            print("SMASH!")
            time.sleep(500)
            print("BASH!")
            time.sleep(500)
            print("Oo!")
            time.sleep(500)
            random_number = random.randint(10)

            if player_strength > random_number:
                print("You won! Gain one strength!")
                player_strength = player_strength + 1
                ogre_strength = ogre_strength - 1
            else:
                print("You lost! Lose one strength!")
                player_strength = player_strength - 1
                ogre_strength = ogre_strength + 1
            if player_strength < 1:
                print("Oh no! You died!")
                sys.exit()

    elif decision == "R" or decision == "r":
        print("You turn right and see a terrible spider!")

        spider_strength = 2
        while player_strength > 0 and spider_strength > 0:
            print("You FIGHT!")
            print("SMASH!")
            time.sleep(500)
            print("BASH!")
            time.sleep(500)
            print("Oo!")
            time.sleep(500)
            random_number = random.randint(10)

            if player_strength > random_number:
                print("You won! Gain one strength!")
                player_strength = player_strength + 1
                spider_strength = spider_strength - 1
            else:
                print("You lost! Lose one strength!")
                player_strength = player_strength - 1
                spider_strength = spider_strength + 1
            if player_strength < 1:
                print("Oh no! You died!")
                sys.exit()

    else:
        print("You turn back, coward! Goodbye!")
        sys.exit()
else:
    print("A hole opens up below you, and you plunge into darkness. Goodbye!")
    sys.exit()

Note, again, how we're using blank whitespace lines to divide up the code to make it more readable, but there's another way we can help people to understand our code...

[Home > Part 2 > Next]