Game Development Reference
In-Depth Information
Asteroid motion described by physics
13-1 , we see a number of asteroids against the familiar starry background. Each asteroid
side. When the asteroids collide, they bounce off each other like pool balls. The smaller asteroids are
defined to have a lower mass; hence, they tend to bounce off the larger asteroids, while the larger
asteroids tend to plow through the smaller ones.
In previous chapters, each actor in the game recorded its state within the game scene and then the
GameControlle r was responsible for using the state of each actor to figure out where it should be
drawn on the screen. In this chapter, we are still following that same pattern, but we are using Box2D
to tell us where each actor is in the scene. Before we look at how this is implemented, let's get an
overview of Box2D and understand its principles; this will make the explanation of the code more clear.
An Overview of Box2D
Box2D is a 2D physics engine for games. It is a library written in C++ so it can be used on a wide
range of platforms and is available under the permissive zlib open-source licenses. In addition to the
primary C++ version of Box2D, there are a large number of ports to other platforms, including Java,
C#, JavaScript, and a few others. The main developer and driver of the project is Erin Catto, who
can be contacted through the forum on the Box2D website: http://www.box2d.org .
Note Information about the zlib licenses can be found here:
http://en.wikipedia.org/wiki/Zlib_License
 
Search WWH ::




Custom Search