O'Reilly logo

Ruby For Kids For Dummies by Christopher Haupt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Project 11

Tower

You can use computer graphics to create games, make art, study science, or understand and solve problems. Graphical programming becomes a powerful tool, and when combined with a language like Ruby, it’s relatively easy to get something working with minimal work.

For the Tower project, you’re going to create both a game and a tool to think about a specific algorithm. The program lets you solve the Tower of Hanoi puzzle using graphics and a point-and-click interface. If the name isn’t familiar to you, you’ve probably seen the puzzle, where you move a stack of donutlike disks from one peg to another, without ever allowing a larger disc to sit on top of a small one.

image

Organizing a New Project

You’ll will use Atom to create and edit your program and, like the preceding project, this program’s source code will be stored in multiple files, one for each class you create. Following standard Ruby practice, each file will be named after the class it contains using the lowercase version of the class name. All the files will be stored in the same project directory. The Tower project is another Gosu-based graphical program, but you’ll still use the terminal program to run and test the code.

remember If you haven’t created a development folder already, refer to Project 2 for more information ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required