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

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.