Skip to content

Instantly share code, notes, and snippets.

@cluelesscoder
Created June 14, 2013 01:04
Show Gist options
  • Save cluelesscoder/5778701 to your computer and use it in GitHub Desktop.
Save cluelesscoder/5778701 to your computer and use it in GitHub Desktop.
import random
class Room:
explored = None
def __init__(self, description):
self.desc = description
def explore(self):
if not self.explored:
self.explored = True
#self.setexplored()
print self.desc
next = raw_input("> ")
if self.explored == True:
print "You've already explored this place."
next = raw_input("> ")
if next == "explore":
self.explore()
# def setexplored(self):
# self.explored = True
def wait(randnum):
if randnum == 0:
print "Nothing happens."
if randnum == 1:
print "You hear quiet rustling around you."
if randnum == 2:
print "You feel something brush past you."
next_step()
def next_step():
print "You are in a dark room. You can wait or explore. What do you do?"
while True:
next = raw_input("> ")
if next == "explore":
startroom.explore()
if next == "wait":
randnum = random.randrange(0,2)
wait(randnum)
def start():
startroom = Room("You are in a dark room, but dim light appears to the east.")
eastroom = Room("This is a bright green field.")
next_step()
start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment