Box2D Binary Counter
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. More...
 
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 KeyboardHandler ()
 The keyboard handler. More...
 
void RenderFrame ()
 Render an animation frame. More...
 
void BeginSpeaking ()
 Begin saying the current number in binary. More...
 
void ProcessSpeaking ()
 Process saying the current number in binary. More...
 

Private Attributes

CMyListener m_cContactListener
 Contact listener.
 
bool m_bSpeaking = false
 Is currently saying the current number.
 
bool m_bSpoken = true
 Has finished saying the current number.
 
float m_fSayBitTimer = 0
 Timer to delay saying the next bit.
 
int m_nCurBit = 0
 Index of the bit currently being said.
 

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 eGameState m_eGameState = eGameState::Start
 Current game state.
 
static CCounterm_pCounter = nullptr
 Pointer to a counter.
 
static UINT m_nCurNum = 0
 Current number.
 

Detailed Description

The game class.

Constructor & Destructor Documentation

◆ ~CGame()

CGame::~CGame ( )

Destructor.

Delete the Renderer and the Object Manager. Also delete Physics World, which MUST be deleted after the Object Manager because of way things are set up.

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.

◆ BeginSpeaking()

void CGame::BeginSpeaking ( )
private

Begin saying the current number in binary.

Begin the speaking process by setting the flag, setting the current bit to the most-significant one, and zeroing out the timer so that the first bit is said immediately.

◆ 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.

Poll the keyboard state and respond to the key presses that happened since the last frame.

◆ 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.

◆ ProcessSpeaking()

void CGame::ProcessSpeaking ( )
private

Process saying the current number in binary.

Do the processing and preparation necessary for saying the current number out loud in binary form. This function should be called once per frame.

◆ 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.