![]() |
Box2D Cannon Game With Stars
Ian Parberry's "Introduction to Game Physics"
|
The object manager. More...
#include <ObjectManager.h>
Public Member Functions | |
CObjectManager () | |
Constructor. | |
~CObjectManager () | |
Destructor. More... | |
void | CreateWorldEdges () |
Create the edges of the world. More... | |
void | CreateObject (eSprite, b2Body *) |
Create new object. More... | |
void | CreateTower () |
Create a tower of crates. More... | |
void | clear () |
Reset to initial conditions. More... | |
void | Draw () |
Draw all objects. | |
void | EmitSmoke (const Vector2 &, Vector2) |
Emit a smoke particle. More... | |
const bool | AllCratesBelow (float) const |
Test all crates below height. More... | |
Private Member Functions | |
void | CreateCrate (float, float, const b2FixtureDef &) |
Create a crate. More... | |
Private Attributes | |
LParticleDesc2D | m_cSmokeDesc |
Particle descriptor for smoke particle. | |
std::vector< CObject * > | m_stdList |
Object list. | |
Additional Inherited Members | |
![]() | |
static b2World * | m_pPhysicsWorld = nullptr |
Pointer to Box2D Physics World. | |
static CRenderer * | m_pRenderer = nullptr |
Pointer to Render World. | |
static CObjectManager * | m_pObjectManager = nullptr |
Pointer to object manager. | |
static LParticleEngine2D * | m_pParticleEngine = nullptr |
Pointer to particle engine. | |
static bool | m_bEasterEgg = false |
Easter egg! | |
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.
const bool CObjectManager::AllCratesBelow | ( | float | h | ) | const |
Test all crates below height.
h | Height in Render World units. |
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.
|
private |
Create a crate.
Create a crate in Physics World and Object World.
x | Horizontal coordinate in Physics World units. |
y | Vertical coordinate in Physics World units. |
fd | Crate fixture definition. |
void CObjectManager::CreateObject | ( | eSprite | t, |
b2Body * | p | ||
) |
Create new object.
Create an object in the object manager.
t | Sprite type. |
p | Pointer to Physics World body. |
void CObjectManager::CreateTower | ( | ) |
Create a tower of crates.
Create a tower of crates at a hard-coded location.
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.
void CObjectManager::EmitSmoke | ( | const Vector2 & | p, |
Vector2 | v | ||
) |
Emit a smoke particle.
Create a smoke particle using the front particle engine so that it appears in front of the cannon. This particle will scale in and fade out over its lifespan, which is hard-coded. Friction is added to make it slow down horizontally, and upward acceleration is added to make it appear to rise due to the high temperature of an expolosion.
p | Initial position. |
v | Initial velocity. |