O'Reilly logo

Learn Game Programming with Ruby by Mark Sobkowicz

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

Turn Rules into Code

The rules of the game seem simple enough. A drag is valid if it’s within a row or a column, and if the two squares are the same color, and if there are no other squares between them. The drag can end on the second square, or it can continue onto empty squares beyond the second square. In this section you write the method, move(square1, square2), that makes these rules part of the game.

Make a Flowchart

To help you get from the rules to code, create a flowchart. A flowchart is a diagram that represents a set of rules in an organized way. Just making a flowchart like this can help you clarify what you really mean when you state the rules of a game. In a flowchart, conditionals are represented with diamonds, and calculations ...

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