![]() |
Box2D Joint Toy
Ian Parberry's "Introduction to Game Physics"
|
The object manager. More...
#include <ObjectManager.h>
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 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. | |
The object manager.
The object manager is an abstract representation of all of the objects in the game.
CObjectManager::~CObjectManager | ( | ) |
Destructor.
The destructor clears the object list, which destructs all of the objects in it.
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 new object.
Create an object in the object manager.
t | Sprite type. |
b | Pointer to Physics World body. |
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.
b0 | Pointer to first physics body. (The base.) |
d0 | Vector offset to anchor point on b0. |
r0 | Radius of b0. |
b1 | Pointer to second physics body. (The dangly bit.) |
d1 | Vector offset to anchor point on b1. |
r1 | Radius of b1. |
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.
bool CObjectManager::DeleteObject | ( | eSprite | t | ) |
Delete the first object of a given sprite type.
Delete the first object of a given sprite type.
t | Sprite type. |
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.