The Stroop Test Game
Game Physics with a 2D Physics Engine
Loading...
Searching...
No Matches
CMyListener Class Reference

My contact listener.

#include <ContactListener.h>

Inheritance diagram for CMyListener:
Collaboration diagram for CMyListener:

Public Member Functions

void PreSolve (b2Contact *, const b2Manifold *)
 Presolve function.
 

Private Member Functions

int Count (eSprite)
 Count number of bodies that have sprite type t.
 
float GetSpeed (const b2Vec2 &)
 Get the collision speed.
 

Private Attributes

b2Body * m_pBodyA = nullptr
 Pointer to body A.
 
b2Body * m_pBodyB = nullptr
 Pointer to body B.
 

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.
 

Member Function Documentation

◆ Count()

int CMyListener::Count ( eSprite t)
private

Count the number of bodies out of *m_pBodyA and *m_pBodyB that have objects have a given sprite type. Returns 0, 1, or 2, of course.

Parameters
tSprite Type.
Returns
Number of *m_pBodyA and *m_pBodyB that have type t.
Here is the call graph for this function:

◆ GetSpeed()

float CMyListener::GetSpeed ( const b2Vec2 & p)
private

Collision speed is proportional to the magnitude of the relative velocity.

Parameters
pWorld point.
Returns
Collision speed in Physics World units.
Here is the caller graph for this function:

◆ PreSolve()

void CMyListener::PreSolve ( b2Contact * c,
const b2Manifold * m )

Presolve function. Renders a colored star at each contact point and plays the appropriate sound, depending on what type of objects are contacting.

Parameters
cPointer to the contact.
mPointer to the old contact manifold as it was before this contact.
Here is the call graph for this function: