![]() |
The Pinball Game
Ian Parberry's "Introduction to Game Physics"
|
The game class.
#include <Game.h>
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 | |
CObjectManager * | m_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 CRenderer * | m_pRenderer = nullptr |
Pointer to the renderer. | |
static CObjectManager * | m_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. | |
|
private |
Create the edges of the world and some shapes.
void CGame::Initialize | ( | ) |
Initialize the renderer, load the images for the background, and start the game.
|
private |
Poll the keyboard state and respond to the key presses that happened since the last frame.
|
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.
|
private |
Initialize the audio player and load game sounds.
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.
void CGame::Release | ( | ) |
Release all of the DirectX12 objects by deleting the renderer.
|
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.