Feb-06-2019, 12:24 PM
(This post was last modified: Feb-06-2019, 12:25 PM by joshneedshelp.)
I am coding a text based game on python for a school project and i would like the player to have the ability to return to the start if they wish to.
#beginning text# import random import time print("This is the game of stuff, you have to get 6 treasure to win. You might get killed on the way so stay safe.") score = 0 lives = 6 c1 = 0 time.sleep(0.5) print(" Your current score = ", score) print(" You currently have ", lives, "lives remaining") time.sleep(2.1) #castle choice# def start(castle): print("You can choose a possibility of castles to enter, but you will have to enter them all\n You can either enter the fire castle , ice castle or earth castle\n Enter with your own risk") time.sleep(1.8) print("Fire = 1") print("Ice = 2") print("Earth = 3") c1 = int(input("What castle would you like to enter first?")) #room choice for fire castle# if c1 == 1: print("Welcome to the fire castle. There is a possible 3 pieces of treasure hiding in here and it is your job to find them\n Only when you have received 2 of the three treasure pieces you can leave") print("Throne Room = 1") print("Guard Room = 2") print("Dining Room = 3") print("Leave the castle = 4") r1 = int(input("What room would you like to visit?")) #fire throne room# if r1 == 1: print("Welcome to the Throne Room, you can see some unguarded treasure at the end of the room") print("Yes = 1") print("No = 2") y1 = int(input("Would you like to go and get the treasure?")) #fire throne room choice# if y1 == 1: print("you walk towards the treasure and nothing happens, you pick up the treasure and place it in your pocket") score = score + 1 print("You now have ",score," pieces of treasure") print("You now leave the room") elif y1 == 2: print("You leave the room, potentially a wise decision but you may never know") #guard room# elif r1 == 2: print("You walk into the room, the floor instantly collapses underneath you and you fall into the lava") lives = lives - 1 #bedroom# elif r1 == 3: print("You enter the bedroom and see some treasure but it is guarded by a dragon") print("You can either attempt to bluff the dragon, try and kill the dragon or leave the room") print("Bluff = 1") print("Fight = 2") print("Run = 3") bfl = int(input("What would you like to do?")) #bedroom choice# if bfl == 1: print("The dragon sees you and speaks to you") print("DRAGON: 'Hello, you can have the treasure if you complete the riddle, else you will die") print("DRAGON: 'What get's wetter the more it dries'") print("Shower = 1") print("Towel = 2") print("Bath = 3") #bedroom dragon riddle# oo = int(input("What are you going to choose")) if oo == 1: print("DRAGON: Ha ha ha, idiot, now you die") print("The dragon bites your head of and you die") lives = lives - 1 elif oo == 2: print("DRAGON: Correct, well done. You can now have the treasure") print("You put the treasure in your pocket") score = score + 1 elif oo == 3: print("DRAGON:How can you be that stupid?") print("Dragon breathes fire and you burn to death, ouch") lives = lives - 1 else: print("Error in knight's code, incorrect input value") if r1 == 4: print("ok, you may leave but you remember, you must return at some point") start(castle)