Box2D Cannon Game
Chapter 7 of Ian Parberry's "Introduction to Game Physics with Box2D"
 All Classes Files Functions Variables Enumerations Friends 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 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.
 

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

Parameters
xHorizontal coordinate in Physics World units.
yVertical coordinate in Physics World units.
fdBook fixture definition.