![]() |
The Box2D Blank Game
A Blank 2D Game with Box2D and a Contact Listener for Sounds
|
The game class.
#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 | LoadSounds () |
| Load sounds. More... | |
| void | BeginGame () |
| Begin playing the game. More... | |
| void | KeyboardHandler () |
| The keyboard handler. More... | |
| void | RenderFrame () |
| Render an animation frame. More... | |
Private Attributes | |
| CMyListener | m_cContactListener |
| Contact listener. | |
Additional Inherited Members | |
Static Protected Attributes inherited from CCommon | |
| 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 LParticleEngine2D * | m_pParticleEngine = nullptr |
| Pointer to particle engine. | |
| CGame::~CGame | ( | ) |
Call the Renderer'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.
|
private |
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.
| void CGame::Initialize | ( | ) |
Initialize the Renderer and the Object Manager, load images and sounds, start the timer, and begin the game.
|
private |
Poll the keyboard state and respond to the key presses that happened since the last frame.
|
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 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 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.