Project 5

Simple Adventure

For this project, you build a turn-based text adventure game that changes every time you play it. Your player will be trapped inside a randomly generated cavern, be able to find treasure, and occasionally have to defeat a monster.

This project is more involved than your prior projects, but it takes advantage of everything you’ve learned up until now. You’ll get more experience breaking up code into methods that can be reused throughout your program. You’ll also see that methods can be used to hide complicated lines of Ruby to make reading your overall code easier.

image

Organizing a New Project

In this project, you continue to use Atom to create and edit your source code file. You use the terminal program to run and play the Adventure game.

Project 5 will be stored in one Ruby file.

remember If you haven’t created a development folder already, refer to Project 2 for information on how to do that.

  1. Start your terminal program and enter the development folder:

    $ cd development

  2. Create a new directory for this project:

    $ mkdir project05

  3. Move into the new directory:

    $ cd project05

  4. Start Atom by double-clicking its icon.
  5. Create a new source code file by choosing File ⇒ New File.
  6. Save it by choosing File ⇒ Save, and store it in your project05 directory. Call the file ...

Get Ruby For Kids For Dummies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.