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

The game class.

#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 KeyboardHandler ()
 The keyboard handler. More...
 
void RenderFrame ()
 Render an animation frame. More...
 
void Launch ()
 Launch a ball. More...
 

Private Attributes

CObjectManagerm_pObjectManager = nullptr
 Pointer to object manager.
 
LSpriteDesc2D m_cClipDesc0
 Sprite descriptor for clip 0.
 
LSpriteDesc2D m_cClipDesc1
 Sprite descriptor for clip 0.
 
LSpriteDesc2D m_cScoreDesc [NUMSCOREDIGITS]
 Sprite descriptors for score digits.
 
CDynamicCircle * m_pCurBallShape = nullptr
 Pointer to current ball shape.
 

Static Private Attributes

static const UINT NUMSCOREDIGITS = 6
 Number of digits in score.
 

Additional Inherited Members

- Static Protected Attributes inherited from CCommon
static CRendererm_pRenderer = nullptr
 Pointer to the renderer.
 
static CObjectManagerm_pObjectManager = nullptr
 Pointer to the object manager.
 
static UINT m_nMIterations = 4
 Number of motion iterations.
 
static UINT m_nCIterations = 1
 Number of collision iterations.
 
static float m_fFrequency = 60.0f*m_nMIterations
 Frequency, number of physics iterations per second.
 
static eDrawMode m_eDrawMode = eDrawMode::Background
 Draw mode.
 
static bool m_bBallInPlay = false
 Is there a ball currently in play?
 
static UINT m_nScore = 0
 Current score.
 

Member Function Documentation

◆ BeginGame()

void CGame::BeginGame ( )
private

Create the edges of the world and some shapes.

◆ Initialize()

void CGame::Initialize ( )

Initialize the renderer, load the images for the background, and start the game.

◆ KeyboardHandler()

void CGame::KeyboardHandler ( )
private

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

◆ Launch()

void CGame::Launch ( )
private

If there is no ball, create one and place it in the chute ready for launch. Otherwise, assuming that this has been done and the ball is ready to launch, then apply a vertical impulse to it. Add a little bit of randomness to that impulse so that it behaves slightly differently each time.

◆ LoadSounds()

void CGame::LoadSounds ( )
private

Initialize the audio player and load game sounds.

◆ ProcessFrame()

void CGame::ProcessFrame ( )

Handle keyboard input, move the game objects and render them in their new positions and orientations. Notify the audio player at the start of each frame so that it can prevent multiple copies of a sound from starting on the same frame. Notify the timer of the start and end of the frame so that it can calculate frame time.

◆ Release()

void CGame::Release ( )

Release all of the DirectX12 objects by deleting the renderer.

◆ RenderFrame()

void CGame::RenderFrame ( )
private

Ask 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. In addition, draw score and the CLIP_SPRITEs for the gates on top of everything else.