Gingerbread Man
Dark Magus
Korab - the Python programming language lacks a GOTO command, simply because they are a complete mess when used.
What you need to do is put a loop from line 33 until the second last line, that continues to run until the variable loop == 0. Indent everything in that area one more level. I'll post how I did it:
What you need to do is put a loop from line 33 until the second last line, that continues to run until the variable loop == 0. Indent everything in that area one more level. I'll post how I did it:
Code:
#TEXT ADVENTURE GAME
#the menu function:
def menu(list, question):
for entry in list:
print 1 + list.index(entry),
print ") " + entry
return input(question) - 1
#Give the computer some basic information about the room:
items = ["pot plant","painting","vase","lampshade","shoe",]
actions =["drop the key","open the door"]
#The key is in the vase (or entry number 2 in the list above):
keylocation = 2
#You haven't found the key:
keyfound = 0
loop = 1
#Give some introductory text:
print "Last night you went to sleep in the comfort of your own home."
print "Now, you find yourself locked in a room. You don't know how"
print "you got there, or what time it is. In the room you can see"
print len(items), "things:"
for x in items:
print x
print ""
print "The door is locked. Could there be a key somewhere?"
#Get your menu working, and the program running until you find the key:
###########
# LOOK HERE #
###########
# Notice the extra indents, and the while loop
while loop != 0:
while loop == 1:
choice = menu(items,"What do you want to inspect? ")
if choice == 0:
if choice == keylocation:
print "You found a small key in the pot plant."
print ""
keyfound = 1
else:
print "You found nothing in the pot plant."
print ""
elif choice == 1:
if choice == keylocation:
print "You found a small key behind the painting."
print ""
keyfound = 1
else:
print "You found nothing behind the painting."
print ""
elif choice == 2:
if choice == keylocation:
print "You found a small key in the vase."
print ""
keyfound = 1
else:
print "You found nothing in the vase."
print ""
elif choice == 3:
if choice == keylocation:
print "You found a small key in the lampshade."
print ""
keyfound = 1
else:
print "You found nothing in the lampshade."
print ""
elif choice == 4:
if choice == keylocation:
print "You found a small key in the shoe."
print ""
keyfound = 1
else:
print "You found nothing in the shoe."
print ""
if keyfound == 1:
loop = 2
print "you have the key"
print "There are", len(actions), "things you can do:"
print ""
while loop == 2:
choice = menu(actions,"What do you want to do? ")
if choice == 0:
keyfound = 0
loop = 1
print "You dropped the key"
print ""
elif choice == 1:
loop = 0
print "You put the key in and the door unlocks"
print ""
print "Light floods into the room as you open the door to your freedom."