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

Use a Physics Engine

The physics engine is called Chipmunk, and you can include it in your project using the Ruby gem of the same name. The Chipmunk gem provides several classes you can use to create objects. To understand how Chipmunk handles motion and interactions, take a look at some of these classes.

CP::Space

The game will have a single instance of the CP::Space class. This space is the object that holds all the objects that the physics engine manages. When you create a new object, such as a boulder or a platform, you add it to the space. The main method of the space is step, which moves the game move forward in time. You call the step method of the space in the game’s update method. The space also has some properties that affect all the ...

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