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