The Object Manager.
More...
#include <ObjectManager.h>
|
|
Sage::CParticleDesc2D | m_cSmokeDesc |
| | Particle descriptor for smoke.
|
| |
|
Sage::CParticleDesc2D | m_cStarDesc |
| | Particle descriptor for star.
|
| |
|
Sage::CParticleDesc2D | m_cPopDesc |
| | Particle descriptor for ball pop.
|
| |
|
std::vector< CObject * > | m_stdList |
| | Object list.
|
| |
|
b2Body * | m_pBellBody [NUMBELLS] = {nullptr} |
| | Pointers to bell bodies.
|
| |
|
b2Body * | m_pEdges = nullptr |
| | Pointer to body for world edges and ledge.
|
| |
|
|
static b2World * | m_pPhysicsWorld = nullptr |
| | Pointer to Box2D Physics World.
|
| |
|
static CBox2DRenderer * | m_pRenderer = nullptr |
| | Pointer to Render World.
|
| |
|
static CObjectManager * | m_pObjectManager = nullptr |
| | Pointer to the Object Manager.
|
| |
|
static Sage::CParticleEngine2D * | m_pFrontParticleEngine = nullptr |
| | Pointer to front particle engine.
|
| |
|
static Sage::CParticleEngine2D * | m_pBackParticleEngine = nullptr |
| | Pointer to front particle engine.
|
| |
|
static CCannon * | m_pCannon = nullptr |
| | Pointer to a cannon.
|
| |
|
static Vector2 | m_vBellPos [NUMBELLS] = {Vector2(0.0f)} |
| | Positions of bells.
|
| |
|
static float | m_fGravity = 20.0f |
| | Magnitude of gravity in Render World units.
|
| |
|
static eDrawMode | m_eDrawMode = eDrawMode::Sprites |
| | Draw mode.
|
| |
An abstract representation of all of the objects in the game.
◆ CObjectManager()
| CObjectManager::CObjectManager |
( |
| ) |
|
Initialize the sprite descriptors for the pop, start, and smole animations.
◆ ~CObjectManager()
| CObjectManager::~CObjectManager |
( |
| ) |
|
The destructor clears the object list, which destructs all of the objects in it.
◆ AllBellsRung()
| const bool CObjectManager::AllBellsRung |
( |
| ) |
const |
Test whether all bells have been rung.
- Returns
- true if all balls have rung their bells.
◆ 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.
◆ CreateBell()
| b2Body * CObjectManager::CreateBell |
( |
eSprite | t, |
|
|
const Vector2 & | pos ) |
|
private |
Create a single bell in both Render World and Physics World.
- Parameters
-
| t | Sprite type. |
| pos | Position of the bell in Render World coordinates. |
- Returns
- Pointer to bell body in Physics World.
◆ CreateBells()
| void CObjectManager::CreateBells |
( |
| ) |
|
NUMBELLS bells are created in hard-coded positions, and those positions are recorded in array m_vBellPos[NUMBELLS]. Assumes that there are NUMBELLS consecutive bell sprite types starting at eSprite::BellC.
◆ CreateObject()
| void CObjectManager::CreateObject |
( |
eSprite | t, |
|
|
b2Body * | p ) |
- Parameters
-
| t | Sprite type. |
| p | Pointer to body in Physics World. |
◆ CreateWorldEdges()
| void CObjectManager::CreateWorldEdges |
( |
| ) |
|
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 edge.
◆ 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.
◆ DrawSunflowers()
| void CObjectManager::DrawSunflowers |
( |
| ) |
|
|
private |
Draw sunflowers consisting of a line for the stem, a flower at the top, and a series of even;y spaced leaves going up the stem, getting smaller with height.
◆ ElevateFlower()
| void CObjectManager::ElevateFlower |
( |
UINT | n, |
|
|
float | d ) |
Manually changes a flower's height in both the Object Manager and Physics World.
- Parameters
-
| n | Flower index. |
| d | Amount to add to its height. |
◆ EmitSmoke()
| void CObjectManager::EmitSmoke |
( |
const Vector2 & | p, |
|
|
Vector2 | v ) |
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.
- Parameters
-
| p | Initial position. |
| v | Initial velocity. |
◆ EmitStars()
| void CObjectManager::EmitStars |
( |
| ) |
|
|
private |
Emit a star particle behind each ball that is flagged as an emitter of stars. They go into the back particle engine so that the balls are draw on top of them.
◆ MakeBallsCollide()
| void CObjectManager::MakeBallsCollide |
( |
| ) |
|
|
private |
Ask all balls to make themselves collidable if their state allows it.
◆ RemoveDeadBalls()
| void CObjectManager::RemoveDeadBalls |
( |
| ) |
|
|
private |
Get rid of cannonballs after they have rung their bell and 10 seconds have elapased since the time they rang it. Play a sound and emit a particle too.
◆ step()
| void CObjectManager::step |
( |
| ) |
|
Emit stars from the flying cannon balls, make them collide with each other after they hit, and then remove them after a decent interval.