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

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