Last session when we were writing python code, I had a blast writing the “choose your own adventure” game. First we copied out the code we were provided, and debugged that several times. Once it was finally up and running well, I decided to make some tweaks and add my own flair. I added several more paths to the game. Now after being asked if you want to go left or right, you are asked several more questions.
When we were writing this game, our group decided that it would be hilarious if you died, no matter what path you chose. There is no way to win this game, only different ways to die. My favourite ending of the game is, if the player chooses to swim they find out they aren’t actually able to swim. Then they drown, and the game ends.
Writing this code really helped me understand just how picky code is. I wrote thirty lines of code, only to get several lines of jumbled red error messages. After spending several minutes debugging the code, I found out that the whole problem was caused by a missing quotation mark. The most important thing that I learnt this session was to run your code little bits at a time, so you don’t end up spending hours debugging it.
I had a lot of fun writing this game. Feel free to try it out for yourself, and edit it to make it even more fun. Happy coding!
print “You are in a cave.”
print “There is a path to your Left and a path to your Right.”
path = raw_input(“>”)
if path == “Left”:
print “You see a bear eating cake.”
print “You can Take Cake or Dance.”
bear = raw_input(“>”)
if bear == “Dance”:
print “You and the bear have a dance party, and then you die.”
elif bear == “Take Cake”:
print “You have angered the bear. It eats you.”
print “The bear doesn’t like that. It eats you.”
elif path == “Right”:
print “You see a calm pool of water.”
print “You can Swim or Go Fishing.”
water = raw_input(“>”)
if water == “Swim”:
print “WHOOPS, you can’t swim, you die.”
elif water == “Go Fishing”:
print “You catch a fish! Would you like to Eat or Release?”
fish = raw_input(“>”)
if fish == “Eat”:
print “The fish was poisonous, you die.”
elif fish == “Release”:
print “You have upset the sea monster. You die.”
print “Your answer upets me. You die.”
print “Your answer upsets me. You die.”
print “You should have picked left or right.”
print “Your desicion has offended me! You die.”