Box2D Bouncy Things Toy
Game Physics with a 2D Physics Engine
Loading...
Searching...
No Matches
CObjectManager Class Reference

The object manager. More...

#include <ObjectManager.h>

Inheritance diagram for CObjectManager:
Collaboration diagram for CObjectManager:

Public Member Functions

 CObjectManager ()
 Constructor.
 
 ~CObjectManager ()
 Destructor.
 
void Clear ()
 Reset to initial conditions.
 
void Draw ()
 Draw all objects.
 
void CreateWorldEdges ()
 Create the edges of the world.
 
void CreateCrate (float, float)
 Create a crate.
 
void CreateBall (float, float)
 Create a ball.
 
const size_t GetSize () const
 Get number of objects.
 

Private Attributes

std::vector< CObject * > m_stdList
 Object list.
 
std::vector< b2Body * > m_stdEdgeList
 Edge list.
 

Additional Inherited Members

- Static Protected Attributes inherited from CCommon
static b2World * m_pPhysicsWorld = nullptr
 Pointer to Box2D Physics World.
 
static CBox2DRenderer * m_pRenderer = nullptr
 Pointer to the renderer.
 
static CObjectManagerm_pObjectManager = nullptr
 Pointer to the object manager.
 
static eDrawMode m_eDrawMode = eDrawMode::Sprites
 Draw mode.
 

Detailed Description

The object manager manages objects.

Constructor & Destructor Documentation

◆ ~CObjectManager()

CObjectManager::~CObjectManager ( )

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

Here is the call graph for this function:

Member Function Documentation

◆ Clear()

void CObjectManager::Clear ( )

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.

Here is the caller graph for this function:

◆ CreateBall()

void CObjectManager::CreateBall ( float x,
float y )

Create a ball object and its Box2D body.

Parameters
xHorizontal coordinate in Physics World units.
yVertical coordinate in Physics World units.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateCrate()

void CObjectManager::CreateCrate ( float x,
float y )

Create a crate object and its Box2D body.

Parameters
xHorizontal coordinate in Physics World units.
yVertical coordinate in Physics World units.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateWorldEdges()

void CObjectManager::CreateWorldEdges ( )

Place Box2D edge shapes in the Physics World in places that correspond to the bottom, right, and left edges of the screen. The left and right edges continue upwards for a distance. There is no top to the world.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Draw()

void CObjectManager::Draw ( )

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.

Here is the caller graph for this function:

◆ GetSize()

const size_t CObjectManager::GetSize ( ) const

Reader function for number of objects in the object list.

Returns
Number of objects in object list.
Here is the caller graph for this function: