Box2D Joint Toy
Ian Parberry's "Introduction to Game Physics"
Public Member Functions | Private Member Functions | 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 BeginGame ()
 Begin playing the game. More...
 
void KeyboardHandler ()
 The keyboard handler. More...
 
void RenderFrame ()
 Render an animation frame. More...
 
void DrawBackground ()
 Draw the background. More...
 
void CreateObjects ()
 Create game objects. More...
 

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 CWindmillm_pWindmill = nullptr
 Pointer to windmill.
 
static CGearm_pGear = nullptr
 Pointer to gear system.
 
static CNautilusGearm_pNautilusGear = nullptr
 Pointer to Nautilus gear system.
 
static CRackAndPinionm_pRackAndPinion = nullptr
 Pointer to rack-and-pinion.
 
static CCarm_pCar = nullptr
 Pointer to car.
 
static CRampm_pRamp = nullptr
 Pointer to ramp.
 
static CNewtonsCradlem_pNewtonsCradle = nullptr
 Pointer to Newton's Cradle.
 
static CPulleym_pPulley = nullptr
 Pointer to pulley system.
 
static eLevel m_eCurLevel = eLevel::Windmill
 Current level.
 

Detailed Description

The game class.

Constructor & Destructor Documentation

◆ ~CGame()

CGame::~CGame ( )

Destructor.

Call Render World's Release function to do the required Direct3D cleanup, then 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. Lastly delete the toy's components. All but one of those pointers will be NULL, but who cares?

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.

◆ CreateObjects()

void CGame::CreateObjects ( )
private

Create game objects.

Ask the object manager to create the game objects for the current level.

◆ DrawBackground()

void CGame::DrawBackground ( )
private

Draw the background.

Draw the appropriate background for the current level.

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

◆ ProcessFrame()

void CGame::ProcessFrame ( )

Process an animation frame.

Handle keyboard input, move the game objects and render them in their new positions and orientations.
There's also some extra processing to be done outside Box2D in order to move the nautilus gears, the car, the pulleys, and the rack-and-pinion.

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