![]() |
Box2D Joint Toy
Ian Parberry's "Introduction to Game Physics"
|
The game class. More...
#include <Game.h>
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 b2World * | m_pPhysicsWorld = nullptr |
Pointer to Box2D Physics World. | |
static CRenderer * | m_pRenderer = nullptr |
Pointer to the renderer. | |
static CObjectManager * | m_pObjectManager = nullptr |
Pointer to the object manager. | |
static CWindmill * | m_pWindmill = nullptr |
Pointer to windmill. | |
static CGear * | m_pGear = nullptr |
Pointer to gear system. | |
static CNautilusGear * | m_pNautilusGear = nullptr |
Pointer to Nautilus gear system. | |
static CRackAndPinion * | m_pRackAndPinion = nullptr |
Pointer to rack-and-pinion. | |
static CCar * | m_pCar = nullptr |
Pointer to car. | |
static CRamp * | m_pRamp = nullptr |
Pointer to ramp. | |
static CNewtonsCradle * | m_pNewtonsCradle = nullptr |
Pointer to Newton's Cradle. | |
static CPulley * | m_pPulley = nullptr |
Pointer to pulley system. | |
static eLevel | m_eCurLevel = eLevel::Windmill |
Current level. | |
The game class.
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?
|
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.
|
private |
Create game objects.
Ask the object manager to create the game objects for the current level.
|
private |
Draw the background.
Draw the appropriate background for the current level.
void CGame::Initialize | ( | ) |
Initialize the game.
Initialize the renderer and the object manager, load images and sounds, start the timer, and begin the game.
|
private |
The keyboard handler.
Poll the keyboard state and respond to the key presses that happened since the last frame.
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.
void CGame::Release | ( | ) |
Release the renderer.
Release all of the DirectX12 objects by deleting the renderer.
|
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.