Skip to content

Instantly share code, notes, and snippets.

@Michael0x2a
Last active December 19, 2015 17:29
Show Gist options
  • Save Michael0x2a/5991923 to your computer and use it in GitHub Desktop.
Save Michael0x2a/5991923 to your computer and use it in GitHub Desktop.
An example of a short text-adventure game.
has_paper = False
has_doll = False
def drums():
print "The drums are drummable"
def paper():
if has_paper == True:
print "You already have the paper"
else:
print "You should try taking the paper"
def table():
while True:
print "There are some papers and a munchkin apple doll on the table"
command = raw_input("? ")
if command == "go back":
return
elif command == "look at paper":
paper()
elif command == "take paper":
has_paper = True
else:
print "I don't know what you just said"
def start():
while True:
print "You are standing in a room. It has a table, and a few drums."
command = raw_input("? ")
if command == "look at drums":
drums()
elif command == "look at table":
table()
elif command == "quit":
return
else:
print "I don't know what you just said"
start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment