Box2D Binary Counter
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 ()
 Constructor.
 
 ~CObjectManager ()
 Destructor. More...
 
void CreateObject (eSprite t, b2Body *p)
 Create object.
 
void CreateCounter (int n)
 Create counter. More...
 
bool CreateBall ()
 Create a new ball. More...
 
void clear ()
 Reset to initial conditions. More...
 
void draw ()
 Draw all objects. More...
 
void CreateWorldEdges ()
 Create the edges of the world. More...
 
bool AllStopped ()
 Have the balls stopped moving? More...
 
int HighLightBit (int n)
 Highlight the nth bit.
 
bool Overflow ()
 Test overflow.
 

Private Attributes

std::vector< CObject * > m_stdList
 Object list.
 
LParticleDesc2D m_cRingDesc
 Particle descriptor for ring of arrows.
 
UINT m_nMaxNumber = 0
 Maximum number.
 

Additional Inherited Members

- Static Protected Attributes inherited from CCommon
static b2World * m_pPhysicsWorld = nullptr
 Pointer to Box2D Physics World.
 
static CRendererm_pRenderer = nullptr
 Pointer to the Renderer.
 
static CObjectManagerm_pObjectManager = nullptr
 Pointer to the Object Manager.
 
static LParticleEngine2D * m_pParticleEngine = nullptr
 Pointer to particle engine.
 
static eGameState m_eGameState = eGameState::Start
 Current game state.
 
static CCounterm_pCounter = nullptr
 Pointer to a counter.
 
static UINT m_nCurNum = 0
 Current number.
 

Detailed Description

The Object Manager.

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

◆ AllStopped()

bool CObjectManager::AllStopped ( )

Have the balls stopped moving?

Checks whether all of the balls that are still in play (balls that have fallen to the bottom are not in play) have stopped.

Returns
true if all balls in play have stopped.

◆ clear()

void CObjectManager::clear ( )

Reset to initial conditions.

Delete all of the entities managed by the Object Manager. This involves deleting all of the CObject instances pointed to by the object list, then clearing the object list itself.

◆ CreateBall()

bool CObjectManager::CreateBall ( )

Create a new ball.

Place a ball in Physics World and the Object Manager. The initial position and velocity is hard-coded.

◆ CreateCounter()

void CObjectManager::CreateCounter ( int  n)

Create counter.

Create the counter.

Parameters
nNumber of bits of precision.

◆ CreateWorldEdges()

void CObjectManager::CreateWorldEdges ( )

Create the edges of the world.

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.

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