The Stroop Test Game
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 CreateRandomWord ()
 Create random word.
 
void CreateWorldEdges ()
 Create world edges.
 
void Clear ()
 Reset to initial conditions.
 
void Update ()
 Update all objects.
 
void Draw ()
 Draw all objects.
 
void DrawGameText ()
 Draw game text.
 
void DrawScores ()
 Draw scores.
 
void DeactivateCurrent ()
 Expire all objects.
 
void MakeCurrentExplode ()
 Make the current word explode into characters.
 
void MakeAllExplode ()
 Make all words explode into characters.
 
void ProcessShutdown ()
 Initiate shutdown if the game is finished.
 
void EmitParticle (const Sage::CParticleDesc2D &)
 Create new particle.
 
void StroopWatchesCount ()
 Make Stroop's eyes swivel towards word count.
 
float GetCurrentHt ()
 Get the height of the current word.
 
Vector2 GetCurrentPos ()
 Get the position of the current word.
 
const size_t GetSize () const
 Get number of objects.
 

Private Member Functions

void ExplodeOldWords ()
 Explode old words.
 
void ExplodeOldLetters ()
 Explode old letters.
 
bool AnimateJointExplosion (CObject *)
 Animate a joint explosion.
 
void EmitSpark (const Vector2 &, const Vector2 &)
 Emit a spark.
 
void EmitSmoke (const Vector2 &, const Vector2 &)
 Emit a puff of smoke.
 
void CreateWord (const b2Vec2 &, char *, float, eWordColor)
 
CObjectCreateObject (const CObjDesc &)
 V Create word.
 
void LoadSnideComment ()
 Load snide comment into character buffers.
 
void DrawScore (Sage::CSpriteDesc2D &, int)
 Draw score, which may be negatve.
 

Private Attributes

std::string m_strSnarky
 A snarky comment.
 
std::vector< CObject * > m_stdList
 Object list.
 
Vector2 m_vSize
 Width and height of Render World.
 
b2Body * m_pBody = nullptr
 World body.
 
bool m_bShuttingDown = false
 Are we shutting down?
 
UINT m_nNumCurrent = 0
 Number of characters in the current word.
 

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 renderer.
 
static CObjectManagerm_pObjectManager = nullptr
 Pointer to the object manager.
 
static Sage::CParticleEngine2D * m_pParticleEngine = nullptr
 Pointer to particle engine.

 
static CVectorFieldm_pVectorField = nullptr
 Pointer to a vector field.
 
static CBubbleEnginem_pBubbleEngine = nullptr
 Pointer to a bubble engine.
 
static bool m_bDrawVectors = false
 Do we draw the vector field?
 
static bool m_bDrawPressure = false
 Do we draw the pressures from the vector field?
 
static bool m_bDrawPoints = false
 Do we draw the points from the vector field?
 
static bool m_bDrawParticles = true
 Do we draw particles?
 
static eWordColor m_eCurColor = eWordColor::Black
 Color of the current word.
 
static bool m_bTried = false
 Whether the player has tried on the current word.
 
static UINT m_nWordCnt = INITIAL_WORDCOUNT
 Number of words.
 
static int m_nScore = 0
 Current score, can be negative.
 
static int m_nDelivered = 0
 Number of words delivered.
 
static int m_nExcellent = 0
 Number of words scored as excellent.
 
static int m_nGood = 0
 Number of words scored as excellent.
 
static int m_nFair = 0
 Number of words scored as excellent.
 
static int m_nFailed = 0
 Number of words the player got wrong.
 
static int m_nMissed = 0
 Number of words the player did not attempt.
 
static eGameState m_eGameState = eGameState::Loading
 Current game state.
 
static UINT m_nCntdownNum = 0
 The number we are displaying in the countdown.
 
static CStroopm_pStroop = nullptr
 Pointer to Stroop caricature.
 
static eDrawMode m_eDrawMode = eDrawMode::Sprites
 Draw mode.
 

Detailed Description

An abstract representation of the objects in the game.

Member Function Documentation

◆ AnimateJointExplosion()

bool CObjectManager::AnimateJointExplosion ( CObject * p)
private

Animate the explosion of a joint using the particle engine and vector field.

Parameters
pPointer to an object.
Returns
true if the object has a joint, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Clear()

void CObjectManager::Clear ( )

Reset back to initial conditions. This involves deleting all of the CObject instances pointed to by the object list, then clearing the object list.

Here is the caller graph for this function:

◆ CreateObject()

CObject * CObjectManager::CreateObject ( const CObjDesc & d)
private

Create new object.

Create an object of a specified type, enter it into the object list, and return a pointer to it.

Parameters
dObject descriptor.
Returns
Pointer to the object created.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateRandomWord()

void CObjectManager::CreateRandomWord ( )

Create a word that reads "red", "green", or "blue" pseudorandomly, to be rendered in red, green, or blue chosen pseudorandomly. The initial position of the word is pseudorandmly offset a small amount from the window center line, just above the window so that it is initially out of sight.

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

◆ CreateWord()

void CObjectManager::CreateWord ( const b2Vec2 & pos,
char * txt,
float s,
eWordColor clr )
private
Parameters
posPosition in Physics World.
txtWord in text format, zero terminated.
sScale.
clrColor that text is to be rendered in.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateWorldEdges()

void CObjectManager::CreateWorldEdges ( )

Create world edges in Physics World. Place Box2D edge shapes in the Physics World in places that correspond to the top, 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.

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

◆ DeactivateCurrent()

void CObjectManager::DeactivateCurrent ( )

Make the current word's color eWordColor::Black.

Here is the caller graph for this function:

◆ Draw()

void CObjectManager::Draw ( )

Draw the game objects using Painter's Algorithm:eSprite::Background, then the objects in the object list, then the particles in the particle engine.

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

◆ DrawGameText()

void CObjectManager::DrawGameText ( )

Draw game text appropriate to the game state, including the countdown timer.

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

◆ DrawScore()

void CObjectManager::DrawScore ( Sage::CSpriteDesc2D & d,
int n )
private

Draw a single score. It is assumed that the score is greater than -100 and less than or equal to 100. Bad things happen otherwise.

Parameters
d[in, out] Sprite descriptor.
nScore.
Here is the caller graph for this function:

◆ DrawScores()

void CObjectManager::DrawScores ( )

Draw scores to the window, hopefully over the top of the dashboard, which we assume has been drawn already.

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

◆ EmitParticle()

void CObjectManager::EmitParticle ( const Sage::CParticleDesc2D & d)

Create a particle using the front particle engine. This is a public member function because the contact listener needs to call it.

Parameters
dParticle descriptor.
Here is the caller graph for this function:

◆ EmitSmoke()

void CObjectManager::EmitSmoke ( const Vector2 & pos,
const Vector2 & vel )
private

Create a smoke particle using the front particle engine.

Parameters
posPosition in Render World coordinates.
velVelocity in Render World units.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EmitSpark()

void CObjectManager::EmitSpark ( const Vector2 & pos,
const Vector2 & vel )
private

Create a spark particle using the front particle engine.

Parameters
posPosition in Render World coordinates.
velVelocity in Render World units.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExplodeOldLetters()

void CObjectManager::ExplodeOldLetters ( )
private

Explode any individuals letters left over from old words.

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

◆ ExplodeOldWords()

void CObjectManager::ExplodeOldWords ( )
private

Find all objects in the object list that are not eWordColor::Gray and are older than WORD_EXPLODE_DELAY and trigger a joint explosion if they are in a joint.

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

◆ GetCurrentHt()

float CObjectManager::GetCurrentHt ( )

Get the height of the current word, which is defined to be the average height of the characters in it.

Returns
Average height of current word in Render World units.
Here is the caller graph for this function:

◆ GetCurrentPos()

Vector2 CObjectManager::GetCurrentPos ( )

Get the position of the current word in Render World units. This is obtained by averaging the positions of the letters in it.

Returns
Position of the current word in Render WOrld coordinates.
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.

◆ LoadSnideComment()

void CObjectManager::LoadSnideComment ( )
private

Load a snide comment based on score achieved into the character buffers.

Here is the caller graph for this function:

◆ MakeAllExplode()

void CObjectManager::MakeAllExplode ( )

Make all words explode by resetting their birth times to be close to the current time.

Here is the caller graph for this function:

◆ MakeCurrentExplode()

void CObjectManager::MakeCurrentExplode ( )

Make the current word explode by resetting its birth time to be close to the current time.

Here is the caller graph for this function:

◆ ProcessShutdown()

void CObjectManager::ProcessShutdown ( )

Shutdown process to be called when all of the words have been presented to the player.

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

◆ StroopWatchesCount()

void CObjectManager::StroopWatchesCount ( )

Make the Stroop caricature's eyes swivel towards the word count.

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

◆ Update()

void CObjectManager::Update ( )

Update all of the objects in the object list, explode the old words, move the particles in the particle engine, and update the vector field and the Stroop animation.

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