Box2D Getting Started
Chapter 5 of Ian Parberry's "Introduction to Game Physics with Box2D"
 All Classes Files Functions Variables Enumerations Pages
Functions | Variables
nonplayerobjects.cpp File Reference

Code for the creation of nonplayer objects. More...

#include "gamedefines.h"
#include "Box2D\Box2D.h"
#include "ObjectWorld.h"

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.
 

Detailed Description

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.

Function Documentation

void CreateBall ( float  x,
float  y 
)

Place a ball in Physics World and Object World.

Parameters
xHorizontal coordinate in Physics World units.
yVertical coordinate in Physics World units.
void CreateBook ( float  x,
float  y 
)

Place a book in Physics World and Object World.

Parameters
xHorizontal coordinate in Physics World units.
yVertical 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.