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

The game class.

#include <Game.h>

Inheritance diagram for CGame:
Collaboration diagram for CGame:

Public Member Functions

 ~CGame ()
 Destructor.
 
void Initialize ()
 Initialize the game.
 
void ProcessFrame ()
 Process an animation frame.
 
void Release ()
 Release the renderer.
 

Private Member Functions

void LoadSprites ()
 Start loading sprites.
 
void LoadSounds ()
 Load sounds.
 
void BeginGame ()
 Begin playing the game.
 
void ProcessKey (eWordColor, char)
 Process a keyboard key.
 
void KeyboardHandler ()
 The keyboard handler.
 
void RenderFrame ()
 Render an animation frame.
 
void ProcessState ()
 Process game state.
 

Private Attributes

CMyListener m_cMCL
 My contact listener.
 
float m_fTime = 0.0f
 Time counter.
 

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

◆ BeginGame()

void CGame::BeginGame ( )
private

Clear any old objects out of the Object Manager and create the edges of the game world, which correspond to the edges of the window.

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

◆ Initialize()

void CGame::Initialize ( )

Initialize the renderer and the object manager, load images and sounds, start the timer, and begin the game.

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

◆ KeyboardHandler()

void CGame::KeyboardHandler ( )
private

Respond to a user keystroke.

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

◆ LoadSounds()

void CGame::LoadSounds ( )
private

Load the sounds for this game.

Here is the caller graph for this function:

◆ LoadSprites()

void CGame::LoadSprites ( )
private

Load the sprites for this game.

Here is the caller graph for this function:

◆ ProcessFrame()

void CGame::ProcessFrame ( )

Handle keyboard input, move the game objects and render them in their new positions and orientations. Notify the timer of the start and end of the frame so that it can calculate frame time.

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

◆ ProcessKey()

void CGame::ProcessKey ( eWordColor clr,
char c )
private

Process a color key hit. Play the appropriate sound and make the word explode if the player has hit the correct key, also add an increment to the relevant score category.

Parameters
clrWord color.
cKey that the player pressed.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ProcessState()

void CGame::ProcessState ( )
private

Take action appropriate to the current game state.

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

◆ Release()

void CGame::Release ( )

Release all of the DirectX12 objects by deleting the renderer.

Here is the caller graph for this function:

◆ RenderFrame()

void CGame::RenderFrame ( )
private

Ask the Object Manager to draw the game objects. RenderWorld is notified of the start and end of the frame so that it can let Direct3D do its pipelining jiggery-pokery.

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