Skip to content

Instantly share code, notes, and snippets.

@codebleeder
Created February 24, 2014 01:29
Show Gist options
  • Select an option

  • Save codebleeder/9180203 to your computer and use it in GitHub Desktop.

Select an option

Save codebleeder/9180203 to your computer and use it in GitHub Desktop.
def start_node(possessions):
print 'there are zombies following you!!'
print 'pick one: go \"left\" or go \"right\" '
direction = raw_input('>')
if direction == "left" :
chainsaw_node("start_node",possessions)
elif direction == "right" :
key_node("start_node",possessions)
else :
print 'dude .. theres zombies on our tail .. type correct or u r one dead meat !!'
start_node(possessions)
def chainsaw_node(src,possessions):
if src == "start_node" :
print 'you see a chainsaw and pick it up'
possessions[0] = 1
print 'there are two doors: one on the right and one straight ahead'
print 'options: \"straight\",\"back\",\"right\" '
direction = raw_input('>')
if direction == "straight" :
passage_node("chainsaw_node",possessions)
elif direction == "right" :
key_node("chainsaw_node",possessions)
elif direction == "back" :
start_node(possessions)
else :
print 'dude .. theres zombies on our tail .. type correct or u r one dead meat !!'
chainsaw_node("start_node",possessions)
elif src == "key_node" :
if possessions[0] != 1:
print 'you see a chainsaw and pick it up'
possessions[0] = 1
else:
pass
print 'there are two doors: one on the right and one on the left'
print 'options: \"left\",\"right\",\"back\" '
direction = raw_input('>')
if direction == "left" :
start_node(possessions)
elif direction == "right" :
passage_node("chainsaw_node",possessions)
elif direction == "back" :
key_node("chainsaw_node",possessions)
else :
print 'dude .. theres zombies on our tail .. type correct or u r one dead meat !!'
chainsaw_node("key_node",possessions)
elif src == "passage_node":
if possessions[0] != 1:
print 'you see a chainsaw and pick it up'
possessions[0] = 1
else:
pass
print 'there are 2 doors: \"left\" and \"straight\" ahead'
direction = raw_input('>')
if direction == "left" :
key_node("chainsaw_node",possessions)
elif direction == "straight" :
start_node(possessions)
else :
print 'dude .. theres zombies on our tail .. type correct or u r one dead meat !!'
chainsaw_node("passage_node",possessions)
else:
print 'wrong destination !!'
def key_node(src,possessions):
if possessions[1] == 0 :
print 'you see a key lying on a table and pick it up'
possessions[1] = 1
else :
pass
if src == "start_node":
print 'you see a door \"straight\" ahead and a door on your \"left\" '
direction = raw_input('>')
if direction == "straight":
passage_node("key_node",possessions)
elif direction == "left" :
chainsaw_node("key_node",possessions)
else :
print 'wrong direction !! '
elif src == "chainsaw_node" :
print 'you see a door on your \"right\" and a door on your \"left\" '
direction = raw_input('>')
if direction == "right":
start_node(possessions)
elif direction == "left" :
passage_node("key_node",possessions)
else :
print 'wrong option typed'
elif src == "passage_node" :
print 'you see a door \"straight\" ahead, a door on your \"right\" or go \"back\"'
direction = raw_input('>')
if direction == "straight" :
start_node(possessions)
elif direction == "right" :
chainsaw_node("key_node", possessions)
elif direction == "back" :
passage_node("key_node",possessions)
else:
print 'wrong option dude !!!'
key_node("passage_node",possessions)
else:
pass
def passage_node(src,possessions):
if src == "key_node" :
print 'you see a door on your \"right\" and a passage \"straight\" ahead'
direction = raw_input('>')
if direction == "right" :
boss_node(possessions)
elif direction == "straight" :
chainsaw_node("passage_node",possessions)
else:
print 'wrong argument !!'
passage_node("key_node",possessions)
elif src == "chainsaw_node" :
print 'you see a door on your \"left\" and a passage \"straight\" ahead'
direction = raw_input('>')
if direction == "left" :
boss_node(possessions)
elif direction == "straight" :
key_node("passage_node",possessions)
else :
print 'wrong option typed !!'
passage_node("chainsaw_node",possessions)
elif src == "boss_node" :
print 'the passage leads to either \"left\" or \"right\" '
direction = raw_input('>')
if direction == "left" :
key_node("passage_node",possessions)
elif direction == "right" :
chainsaw_node("passage_node",possessions)
else :
print 'wrong option typed !!'
passage_node("boss_node",possessions)
else :
pass
def boss_node(possessions):
print 'what the hell !! .. a zombie facing you and the locked escape door right behind !!'
if possessions[0] == 1 :
print 'you take your chainsaw and cut the zombie\'s stupid head .. bloody !!'
if possessions[1] == 1:
print 'you unlock the door and escape to your freedom !!!'
print 'you won !!!'
else :
print 'what the hell!! .. you dont have key to the locked door !!'
print 'go back and get the key !!'
passage_node("boss_node",possessions)
else :
print 'you dont have a weapon to defend yourself and you become dead meat .. :( '
print 'game over'
# main program
print 'Wel come to zombiescape !!'
# initialize a list
possessions = [0,0]
start_node(possessions)
@codebleeder
Copy link
Author

This is a small game where you try to escape from the zombies following you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment