The Stroop Test Game
Ian Parberry's "Introduction to Game Physics"
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CGame Class Reference

The game class. More...

#include <Game.h>

Inheritance diagram for CGame:
CCommon

Public Member Functions

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

Private Member Functions

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

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 CRendererm_pRenderer = nullptr
 Pointer to the Renderer.
 
static CObjectManagerm_pObjectManager = nullptr
 Pointer to the Object Manager.
 
static LParticleEngine2D * 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 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.
 

Detailed Description

The game class.

Member Function Documentation

◆ BeginGame()

void CGame::BeginGame ( )
private

Begin playing the game.

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.

◆ Initialize()

void CGame::Initialize ( )

Initialize the game.

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

◆ KeyboardHandler()

void CGame::KeyboardHandler ( )
private

The keyboard handler.

Respond to a user keystroke and report back if the user hit the Esc key, indicating that we should shut down.

Returns
true if the user hits Esc.

◆ LoadSounds()

void CGame::LoadSounds ( )
private

Load sounds.

Initialize the audio player and load game sounds.

◆ ProcessFrame()

void CGame::ProcessFrame ( )

Process an animation frame.

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.

◆ ProcessKey()

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

Process a keyboard key.

Process a color key hit. Play appropriate sound, make the word explode if it's the correct key, add increment to the relevant score.

◆ Release()

void CGame::Release ( )

Release the renderer.

Release all of the DirectX12 objects by deleting the renderer.

◆ RenderFrame()

void CGame::RenderFrame ( )
private

Render an animation frame.

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.