Bullet Physics Block Toy
Game Physics with a 3D Physics Engine
Loading...
Searching...
No Matches
CGame Class Reference

The game class. More...

#include <Game.h>

Inheritance diagram for CGame:
Collaboration diagram for CGame:

Public Member Functions

 ~CGame ()
 Destructor.
 
void Initialize ()
 Initialize the game.
 
void ProcessFrame ()
 Process an animation frame.
 
void Release ()
 Release the renderer.
 

Private Member Functions

void LoadSounds ()
 Load sounds.
 
void BeginGame ()
 Begin playing the game.
 
void KeyboardHandler ()
 The keyboard handler.
 
void ControllerHandler ()
 The controller handler.
 
void RenderFrame ()
 Render an animation frame.
 
void CreateObjects ()
 Create game objects.
 
void InitBulletPhysics ()
 Initialize Bullet Physics engine.
 
void Fire ()
 Fire a ball.
 

Private Attributes

float m_fStartTime = 0
 Game start time.
 

Additional Inherited Members

- Protected Attributes inherited from CCommon
const float m_fFloorHt = 1.0f
 Floor height.
 
const Vector3 m_vPlanePos
 Plane position.
 
const Vector3 m_vPlaneSize
 Plane size.
 
const bool m_bWireFrame = false
 Draw in wireframe.
 
const float m_fMoonRadius = 25.0f
 Moon radius.
 
const float m_fBallRadius = 2.0f
 Ball radius.
 
const Vector3 m_vBoxSize = Vector3(9.0f, 6.0f, 6.0f)
 Box size.

 
const float m_fTetrahedronSize = 16.0f
 Tetrahedron size.
 
const float m_fIcosahedronSize = 16.0f
 Icosahedron size.
 
const float m_fDodecahedronSize = 16.0f
 Dodecahedron size.
 
const float m_fTeapotSize = 8.0f
 Teapot size.
 
- Static Protected Attributes inherited from CCommon
static CRendererm_pRenderer = nullptr
 Pointer to the renderer.
 
static Sage::CCamera * m_pCamera = nullptr
 Pointer to the camera.
 
static CObjectManagerm_pObjectManager = nullptr
 Pointer to object manager.
 
static btDiscreteDynamicsWorld * m_pPhysicsWorld = nullptr
 Pointer to physics engine.
 
static btDefaultCollisionConfiguration * m_pConfig = nullptr
 Bullet physics configuration.
 
static btCollisionDispatcher * m_pDispatcher = nullptr
 Bullet physics dispatcher.
 
static btBroadphaseInterface * m_pBroadphase = nullptr
 Bullet physics broadphase.
 
static btSequentialImpulseConstraintSolver * m_pSolver = nullptr
 Bullet physics constraint solver.
 
static btAlignedObjectArray< btCollisionShape * > m_btCollisionShapes
 Collision shapes.
 
static bool m_bCollisionSoundsMuted = false
 Mute collision sounds.
 

Detailed Description

The game class encapsulates our game/toy/whatever.

Constructor & Destructor Documentation

◆ ~CGame()

CGame::~CGame ( )

The destructor deletes the object manager, the Bullet collision shapes, the collision configuration, the collision dispatcher, the broad phase, the sequential impulse constraint solver, and the physics world,

Member Function Documentation

◆ BeginGame()

void CGame::BeginGame ( )
private

Start a new game. Clear the object manager and create new game objects.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ControllerHandler()

void CGame::ControllerHandler ( )
private

Controller handler. Poll the controller and react to the relevant controls.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateObjects()

void CGame::CreateObjects ( )
private

Create the game objects.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fire()

void CGame::Fire ( )
private

Fire a small sphere from the camera location in the direction of its view vector using an impulse with a fixed magnitude.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitBulletPhysics()

void CGame::InitBulletPhysics ( )
private

Initialize the Bullet Physics engine. Create a default collision configuration, a collision dispatcher, a default broad phase, and a sequential impulse constraint solver. These are then used to create the physics world, which is a discrete dynamics world. The gravity is set to a hard-coded value.

Here is the caller graph for this function:

◆ Initialize()

void CGame::Initialize ( )

Create and initialize the renderer. Load geometric primitives and models. Initialize the sound manager and load the sounds. Create the object manager and create and initialize the step timer. Initialize the physics engine and set its tick callback to myTickCallback(). Set the camera's initial position and begin the game.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ KeyboardHandler()

void CGame::KeyboardHandler ( )
private

Keyboard handler.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadSounds()

void CGame::LoadSounds ( )
private

Initialize the audio player and load game sounds.

Here is the caller graph for this function:

◆ ProcessFrame()

void CGame::ProcessFrame ( )

Process an animation frame. Handle keyboard and controller input, advance the timer a tick, perform a physics world step, update all objects, and finally render them.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Release()

void CGame::Release ( )

Release all of the DirectX12 objects by deleting the renderer.

Here is the caller graph for this function: