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 ...

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.