Learn Ruby the Hard Way – Exercise 36 Designing and Debugging

Here is my work for Exercise 36.

Unlike the majority of exercises so far, Exercise 36 does not have code for you to type. Instead, you are given homework to create a Choose-your-own-adventure game similar to the one in Exercise 35. Zed Shaw encourages you to use what you have learned so far: modules, arrays, boolean expressions, functions… etc.

I didn’t have any pen and paper on hand, so instead of doing a flow chart, I simply used bullet points to plan my game. I decided to base my game on the movie, Cabin in the Woods. If you haven’t seen the movie, it’s a horror comedy film produced by Joss Whedon. I think that’s convincing enough to give it a watch. (I quite enjoyed the humour and satire!) In my game, there are a few objects that will trigger different monsters. First I decided on the objects: a dress, a necklace, and a conch shell. The dress is connected to the necklace but only the necklace triggers the bride of Frankenstein. The conch shell will trigger the Merman. (Originally I had a werewolf in there too, but sadly he was eliminated. :P)

Here is my game flow chart: (created after… :P)

Cabin in the Woods inspired Choose-Your-Own-Adventure
Cabin in the Woods inspired Choose-Your-Own-Adventure

My game code is available on github.

Summary
I used modules for the Merman and the Bride of Frankenstein. To get the user’s choice, I used standard input gets and comparison operators to check the choice. I also used loops and arrays to get input, store values, and calculate array sums. I used a while loop to get the user to fight the bride of Frankenstein.

I found that both the design and the implementation of the code required time! This was a good exercise in designing a simple choose-your-own-adventure game and reviewing the concepts I have learned so far.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s