Box2D Getting Started
Chapter 5 of Ian Parberry's "Introduction to Game Physics with Box2D"
|
Code for the creation of nonplayer objects. More...
Functions | |
void | CreateWorldEdges () |
void | CreateBook (float x, float y) |
void | CreateBall (float x, float y) |
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 CreateBall | ( | float | x, |
float | y | ||
) |
Place a ball in Physics World and Object World.
x | Horizontal coordinate in Physics World units. |
y | Vertical coordinate in Physics World units. |
void CreateBook | ( | float | x, |
float | y | ||
) |
Place a book in Physics World and Object World.
x | Horizontal coordinate in Physics World units. |
y | Vertical coordinate in Physics World units. |
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. The left and right edges continue upwards for a distance. There is no top to the world.