Box2D Cannon Game
Chapter 7 of Ian Parberry's "Introduction to Game Physics with Box2D"
|
Code for the creation of nonplayer objects. More...
Functions | |
void | CreateWorldEdges () |
void | PlaceBook (float x, float y, const b2FixtureDef &fd) |
void | CreateTower () |
Create a tower of books at the default location. | |
Variables | |
b2World | g_b2dPhysicsWorld |
CObjectWorld | g_cObjectWorld |
The Object World. | |
Code for the creation of nonplayer objects.
Creating things with a physics engine means a lot of tedious, intricate initialization code. It makes sense to hide it in a file of its own. It's not that it's so difficult, but that there is so much of it. There are so many niggly little details to get right
void CreateWorldEdges | ( | ) |
Create world edges in Physics World. Place Box2D edge shapes in the Physics World in places that correspond to the top, bottom, right, and left edges of the screen in Render World, and a ledge for the cannon to sit upon. The left and right edges continue upwards for a distance. There is no top to the world.
void PlaceBook | ( | float | x, |
float | y, | ||
const b2FixtureDef & | fd | ||
) |
Place a book in Physics World and Object World.
x | Horizontal coordinate in Physics World units. |
y | Vertical coordinate in Physics World units. |
fd | Book fixture definition. |