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

Make Boulders Fall

In Chapter 4, Creating a Sprite-Based Game, you learned to make classes for each type of sprite in the game. You made classes for the player ship, for the enemies, and for bullets and explosions. When you create sprites that will be moved by the physics engine, you still make classes, but those classes do things a little differently.

Bodies, Shapes, and Images

When you add a boulder to the game, you describe it by giving it some physical properties and a shape, and then you add it to the space. You also give it an image that matches its shape. If the image you choose and the shape you define match up reasonably well, the illusion of bouncing, spinning boulders is convincing. If they don’t, the boulders look strange as they ...

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