This is my first Python text-based game. Let me know if there is something I should improve on or fix in the way that my code is written because I feel that I am being very redundant in my code, but I'm just learning this stuff.
Also note that note.txt
just says:
this cabin will self destruct in.....
#Lost In the Woods - A simple text based game
from sys import exit
def start():
print "You are in the middle of the woods alone and scared!"
print "There is no one around but yourself."
print "You look around and wonder....."
print "What will you do?"
print "1.move forward\n2.stay still"
choice = raw_input("> ")
if "move" in choice:
bear_fight()
else:
print "Well your still at the same spot."
start()
def bear_fight():
print "Ahead of you is a huge hungry bear with razor sharp claws"
print "Hes looks angry too!"
print "Do you....."
print "1.throw rock\n2.play dead\n3.run away\n"
choice = raw_input("> ")
if "run" in choice:
print "Duhhh.... Did you think you can out run a bear?"
dead("The bear catches up and has you for dinner, Good Job")
elif "play dead" in choice:
print "The bear laughs at you and chews but off."
dead("You lost your but and lost this game")
else:
print "You deafted the bear with a rock! Hows that possible?"
print "Anyways, You contine to move forward untill......"
cabins()
def cabins():
print "You come acroos two cabins."
print "One of the left and one on the right"
print "Whcih cabin do you pick?"
print "1.left\n2.right\n"
choice = raw_input("> ")
if "left" in choice:
cabin_one()
else:
cabin_two()
def cabin_two():
print "You apprach the cabin on the right."
print "You notice a note on the cabin door."
print "Will you......"
print "1.read the note\n2.open the door"
choice = raw_input("> ")
if "read" in choice:
letter = open("note.txt", 'r')
print letter.read()
letter.close()
for count in range(10, 0, -1):
print count
dead("The cabin explodes and you die")
else:
print "As you walk into the cabin"
print "You slip on a toy car and crack you skull!"
dead("Good job, mabey you should have read the note first!")
def cabin_one():
print "You enter the cabin and decide to spend then night."
print "You wake up the next morning and go outside."
print "You notice the bight sun and a dustty trail on the ground."
print "Will you follow the sun or follow the trail"
print "1.follow sun\n2.follow trail"
choice = raw_input("> ")
if "sun" in choice:
the_sun()
else:
the_path()
def the_sun():
print "You sweet to death and die!"
dead("Follow the path next time dummy")
def the_path():
print "the path leads to a long road."
print "How will you get home from here?"
print "1.hich-hike\n2.walk the road"
choice = raw_input("> ")
if "hich" in choice:
print "No bobdy comes for you."
dead("You starve to death and die")
else:
print "You see civiliztion and stop at the first buger king."
win("Congrats you win this silly game!")
def dead(msg):
print msg + "!!!"
exit(0)
def win(msg):
print msg
exit(0)
start()
for count in range(10, 0, -1): print count
prints numbers immediately, doesn't it? It would be nice to wait a bit before printing. \$\endgroup\$