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

Get Learn Game Programming with Ruby now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.