Make Stationary Walls and Platforms

Many of the objects in the game are stationary. When a boulder hits a platform, it will bounce and tumble, but the platform won’t move at all. You also add walls to keep things from falling off the edges of the game, as well as a floor at the bottom. Chipmunk provides a way to add objects to the game that interact with all the other objects in the space but that do not move themselves.

Static Bodies

When you made your boulders, you started by giving them a body that had a mass and a rotational inertia. The platforms and walls don’t have those properties; they simply don’t move no matter what hits them. Chipmunk provides a special initializer for CP::Body that creates just such a static body, new_static. It’s ...

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.