Created
June 28, 2012 17:38
-
-
Save chriszf/3012755 to your computer and use it in GitHub Desktop.
Game sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
import puppies
ImportError: No module named puppies
i like your code