Box2D Joint Toy
Ian Parberry's "Introduction to Game Physics"
Public Member Functions | Private Attributes | List of all members
CObjectManager Class Reference

The object manager. More...

#include <ObjectManager.h>

Inheritance diagram for CObjectManager:
CCommon

Public Member Functions

 ~CObjectManager ()
 Destructor. More...
 
CObject * create (eSprite, b2Body *)
 Create new object. More...
 
CLineObject * CreateLine (b2Body *, const b2Vec2 &, bool, b2Body *, const b2Vec2 &, bool)
 Create new line object. More...
 
void clear ()
 Reset to initial conditions. More...
 
void draw ()
 Draw all objects. More...
 
void CreateWorldEdges ()
 Create world edges. More...
 
bool DeleteObject (eSprite)
 Delete the first object of a given sprite type. More...
 

Private Attributes

std::vector< CObject * > m_stdList
 Object list.
 
std::vector< CLineObject * > m_stdLineList
 Line list.
 

Additional Inherited Members

- Static Protected Attributes inherited from CCommon
static b2World * m_pPhysicsWorld = nullptr
 Pointer to Box2D Physics World.
 
static CRenderer * m_pRenderer = nullptr
 Pointer to the renderer.
 
static CObjectManager * m_pObjectManager = nullptr
 Pointer to the object manager.
 
static CWindmill * m_pWindmill = nullptr
 Pointer to windmill.
 
static CGear * m_pGear = nullptr
 Pointer to gear system.
 
static CNautilusGear * m_pNautilusGear = nullptr
 Pointer to Nautilus gear system.
 
static CRackAndPinion * m_pRackAndPinion = nullptr
 Pointer to rack-and-pinion.
 
static CCar * m_pCar = nullptr
 Pointer to car.
 
static CRamp * m_pRamp = nullptr
 Pointer to ramp.
 
static CNewtonsCradle * m_pNewtonsCradle = nullptr
 Pointer to Newton's Cradle.
 
static CPulley * m_pPulley = nullptr
 Pointer to pulley system.
 
static eLevel m_eCurLevel = eLevel::Windmill
 Current level.
 

Detailed Description

The object manager.

The object manager is an abstract representation of all of the objects in the game.

Constructor & Destructor Documentation

◆ ~CObjectManager()

CObjectManager::~CObjectManager ( )

Destructor.

The destructor clears the object list, which destructs all of the objects in it.

Member Function Documentation

◆ clear()

void CObjectManager::clear ( )

Reset to initial conditions.

Delete all of the entities managed by object manager. This involves deleting all of the CObject instances pointed to by the object list, then clearing the object list itself. Ditto for the line list.

◆ create()

CObject * CObjectManager::create ( eSprite  t,
b2Body *  b 
)

Create new object.

Create an object in the object manager.

Parameters
tSprite type.
bPointer to Physics World body.
Returns
Pointer to the object created.

◆ CreateLine()

CLineObject * CObjectManager::CreateLine ( b2Body *  b0,
const b2Vec2 &  d0,
bool  r0,
b2Body *  b1,
const b2Vec2 &  d1,
bool  r1 
)

Create new line object.

Create a line object in object manager. Lines have their own list do that they can be drawn behind the other objects.

Parameters
b0Pointer to first physics body. (The base.)
d0Vector offset to anchor point on b0.
r0Radius of b0.
b1Pointer to second physics body. (The dangly bit.)
d1Vector offset to anchor point on b1.
r1Radius of b1.
Returns
Pointer to line object.

◆ CreateWorldEdges()

void CObjectManager::CreateWorldEdges ( )

Create world edges.

Create world edges in Physics World. Place Box2D edge shapes in the Physics World in places that correspond to the 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.

◆ DeleteObject()

bool CObjectManager::DeleteObject ( eSprite  t)

Delete the first object of a given sprite type.

Delete the first object of a given sprite type.

Parameters
tSprite type.
Returns
true if one was actually deleted.

◆ draw()

void CObjectManager::draw ( )

Draw all objects.

Draw the game objects using Painter's Algorithm. The background is drawn first, then the game objects are asked to draw themselves in the order that they are in the object list. That is, they are drawn from back to front. The lines are drawn behind the objects.