![]() |
The Stroop Test Game
Ian Parberry's "Introduction to Game Physics"
|
The Object Manager. More...
#include <ObjectManager.h>
Public Member Functions | |
CObjectManager () | |
Constructor. | |
~CObjectManager () | |
Destructor. | |
void | CreateRandomWord () |
Create random word. More... | |
void | CreateWorldEdges () |
Create world edges. More... | |
void | CreateStroopEdges () |
Create edges of Stroop caricature. More... | |
void | clear () |
Reset to initial conditions. More... | |
void | Update () |
Update all objects. More... | |
void | Draw () |
Draw all objects. More... | |
void | DrawGameText () |
Draw game text. More... | |
void | DrawScores () |
Draw scores. More... | |
void | DeactivateCurrent () |
Expire all objects. More... | |
void | MakeCurrentExplode () |
Make the current word explode into characters. More... | |
void | MakeAllExplode () |
Make all words explode into characters. More... | |
void | ProcessShutdown () |
Initiate shutdown if the game is finished. More... | |
void | EmitParticle (const LParticleDesc2D &) |
void | StroopWatchesCount () |
float | GetCurrentHt () |
Get the height of the current word. More... | |
Vector2 | GetCurrentPos () |
Get the position of the current word. More... | |
const size_t | GetSize () const |
Get number of objects. More... | |
Private Member Functions | |
void | ExplodeOldWords () |
Explode old words. More... | |
void | ExplodeOldLetters () |
Explode old letters. More... | |
bool | AnimateJointExplosion (CObject *) |
Animate a joint explosion. More... | |
void | EmitSpark (const Vector2 &, const Vector2 &) |
Emit a spark. More... | |
void | EmitSmoke (const Vector2 &, const Vector2 &) |
Emit a puff of smoke. More... | |
void | CreateWord (const b2Vec2 &, char *, float, eWordColor) |
CObject * | CreateObject (const CObjDesc &) |
V Create word. More... | |
void | LoadSnideComment () |
Load snide comment into character buffers. More... | |
void | DrawScore (LSpriteDesc2D &, int) |
Draw score, which may be negatve. More... | |
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. | |
bool | m_bShuttingDown = false |
Are we shutting down? | |
UINT | m_nNumCurrent = 0 |
Number of characters in the current word. | |
CStroop | m_cStroop |
Stroop caricature. | |
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 LParticleEngine2D * | m_pParticleEngine = nullptr |
Pointer to particle engine. | |
static CVectorField * | m_pVectorField = nullptr |
Pointer to a vector field. | |
static CBubbleEngine * | m_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 UINT | m_nScore = 0 |
Current score, can be negatice. | |
static UINT | m_nDelivered = 0 |
Number of words delivered. | |
static UINT | m_nExcellent = 0 |
Number of words scored as excellent. | |
static UINT | m_nGood = 0 |
Number of words scored as excellent. | |
static UINT | m_nFair = 0 |
Number of words scored as excellent. | |
static UINT | m_nFailed = 0 |
Number of words the player got wrong. | |
static UINT | m_nMissed = 0 |
Number of words the player did not attempt. | |
static eGameState | m_eGameState = eGameState::Instructions |
Current game state. | |
static UINT | m_nCntdownNum = 0 |
The number we are displaying in the countdown. | |
The Object Manager.
An abstract representation of the objects in the game.
|
private |
Animate a joint explosion.
Animate the explosion of a joint using the particle engine and vector field.
p | Pointer to an object. |
void CObjectManager::clear | ( | ) |
Reset to initial conditions.
Reset back to initial conditions. This involves deleting all of the CObject instances pointed to by the object list, then clearing the object list itself.
V Create word.
Create new object.
Create an object of a specified type, enter it into the object list, and return a pointer to it.
d | Object descriptor. |
void CObjectManager::CreateRandomWord | ( | ) |
Create random word.
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.
void CObjectManager::CreateStroopEdges | ( | ) |
Create edges of Stroop caricature.
Create the edges in the Stroop outline so that the words and characters will bounce off him in a satisfactory manner. I laboriously copied down points on Stroop's outline from a screenshot using an image editor when I was too tired to do any real work yet too jazzed up to relax.
|
private |
pos | Position in Physics World. |
txt | Word in text format, zero terminated. |
s | Scale. |
clr | Color that text is to be rendered in. |
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 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.
void CObjectManager::DeactivateCurrent | ( | ) |
Expire all objects.
Make the current word's color eWordColor::Black.
void CObjectManager::Draw | ( | ) |
Draw all objects.
Draw the game objects using Painter's Algorithm. Draw the eSprite::Background first, then the objects in the object list, then the particles in the particle engine.
draw objects in object list
void CObjectManager::DrawGameText | ( | ) |
Draw game text.
Draw game text appropriate to the game state, including the countdown timer.
|
private |
Draw score, which may be negatve.
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.
d | [in, out] Sprite descriptor. |
n | Score. |
void CObjectManager::DrawScores | ( | ) |
Draw scores.
Draw scores to the window, hopefully over the top of the dashboard, which we assume has been drawn already.
void CObjectManager::EmitParticle | ( | const LParticleDesc2D & | d | ) |
Create a particle using the front particle engine. This is a public member function because the contact listener needs to call it.
d | Particle descriptor. |
|
private |
Emit a puff of smoke.
Create a smoke particle using the front particle engine.
pos | Position in Render World coordinates. |
vel | Velocity in Render World units. |
|
private |
Emit a spark.
Create a spark particle using the front particle engine.
pos | Position in Render World coordinates. |
vel | Velocity in Render World units. |
|
private |
Explode old letters.
Explode any individuals letters left over from old words.
|
private |
Explode old words.
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.
float CObjectManager::GetCurrentHt | ( | ) |
Get the height of the current word.
Get the height of the current word, which is defined to be the average height of the characters in it.
Vector2 CObjectManager::GetCurrentPos | ( | ) |
Get the position of the current word.
Get the position of the current word in Render World units. This is obtained by averaging the positions of the letters in it.
const size_t CObjectManager::GetSize | ( | ) | const |
Get number of objects.
Reader function for number of objects in the object list.
|
private |
Load snide comment into character buffers.
Load a snide comment based on score achieved into the character buffers.
void CObjectManager::MakeAllExplode | ( | ) |
Make all words explode into characters.
Make all words explode by resetting their birth time close to the current time.
void CObjectManager::MakeCurrentExplode | ( | ) |
Make the current word explode into characters.
Make the current word explode by resetting its birth time close to the current time.
void CObjectManager::ProcessShutdown | ( | ) |
Initiate shutdown if the game is finished.
Shutdown process to be called when all of the words have been presented to the player.
void CObjectManager::StroopWatchesCount | ( | ) |
Make the Stroop caricature's eyes swivel towards the current word.
void CObjectManager::Update | ( | ) |
Update all objects.
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.