Skip to content

Instantly share code, notes, and snippets.

@chriszf
Created June 28, 2012 17:38
Show Gist options
  • Save chriszf/3012755 to your computer and use it in GitHub Desktop.
Save chriszf/3012755 to your computer and use it in GitHub Desktop.
Game sample
import sys
import random
import puppies
class CentralCorridor(object):
def play(self):
print "Hey guys this is the central corridor. Neat, huh?"
your_input = raw_input("> ")
if your_input == "death":
return DeathRoom()
elif your_input == "puppies":
return puppies.DeathRoom()
else:
return DeathRoom()
class DeathRoom(object):
def play(self):
print "Nothing but death everywhere."
sys.exit(0)
class GameRunner(object):
def __init__(self, first_room):
self.first_room = first_room
def go(self):
next_room = self.first_room
while True:
next_room = next_room.play()
def main():
game = GameRunner(CentralCorridor())
game.go()
if __name__ == "__main__":
main()
@chicong-dev
Copy link

import puppies
ImportError: No module named puppies
i like your code

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