![]() |
The Pinball Game
Ian Parberry's "Introduction to Game Physics"
|
The object manager. More...
#include <ObjectManager.h>
Public Member Functions | |
~CObjectManager () | |
Destructor. More... | |
CShape * | AddShape (CShapeDesc *, const CObjDesc &) |
Add shape. More... | |
void | move () |
Move all objects. More... | |
void | draw () |
Draw all objects. More... | |
void | DrawOutlines () |
Draw outlines of all objects. More... | |
void | MakeWorldEdges () |
Create shapes for world edges. More... | |
void | MakeShapes () |
Create shapes. More... | |
void | LeftFlip (bool) |
Flip left flipper. More... | |
void | RightFlip (bool) |
Flip right flipper. More... | |
Private Member Functions | |
CShape * | MakeShape (CShapeDesc *, const CObjDesc &) |
Make a shape. More... | |
void | BroadPhase () |
Broad phase collision detection and response. More... | |
bool | NarrowPhase (CShape *, CDynamicCircle *) |
Narrow phase collision detection and response. More... | |
void | MakeBumper (const Vector2 &, float, eSprite, eSprite, eSound) |
Make a bumper. More... | |
void | MakeBollard (const Vector2 &) |
Make a bollard. More... | |
CCompoundShape * | MakeFlipper (const Vector2 &, const Vector2 &, float) |
Make a flipper. More... | |
void | MakeThingL () |
Make a thing (left). More... | |
void | MakeThingR () |
Make a thing (right). More... | |
Private Attributes | |
std::vector< CShape * > | m_stdShapes [(UINT) eMotion::Size] |
Array of lists of shapes. | |
std::vector< CObject * > | m_stdObjects |
Object list. | |
CGate * | m_pLeftGate = nullptr |
Pointer to left gate. | |
CGate * | m_pRightGate = nullptr |
Pointer to right gate. | |
CAabb2D | m_cAABB |
AABB for the whole window. | |
CFlipper * | m_pLeftFlipper = nullptr |
Pointer to left flipper. | |
CFlipper * | m_pRightFlipper = nullptr |
Pointer to right flipper. | |
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. | |
A collection of all of the game objects.
CObjectManager::~CObjectManager | ( | ) |
The destructor clears the shape lists, which destructs all of the shapes in them.
CShape * CObjectManager::AddShape | ( | CShapeDesc * | sd, |
const CObjDesc & | od | ||
) |
Creates a new shape and pushes a contact descriptor for that shape into the shape list.
sd | Pointer to a shape descriptor. |
od | Object descriptor. |
|
private |
Do collision detection for all dynamic shapes against all static and kinematic shapes, and against all dynamic shapes that appear after it in the dynamic shape list.
void CObjectManager::draw | ( | ) |
Draw the sprites for all objects.
void CObjectManager::DrawOutlines | ( | ) |
Draw the outlines of the shapes in all objects.
void CObjectManager::LeftFlip | ( | bool | bUp | ) |
If left flipper isn't moving up, set its rotational velocity to ROTSPEED (with the correct sign indicating direction), and play a sound.
bUp | true for up flip, false for down flip. |
|
private |
A bollard is one of the long skinny things at the top.
p | Position. |
|
private |
A bumper is a round thing that propels the balls at great speed.
p | Position. |
e | Elasticity. |
unlit | Unlit sprite index. |
lit | Lit sprite index. |
snd | Collision sound index. |
|
private |
Flippers are compound shapes made up of 2 circles and 2 line segments.
p | Position of center of rotation. |
d | Offset from position to center of sprite. |
a | Initial orientation. |
|
private |
Create a new shape and a contact descriptor for that shape.
sd | Pointer to a shape descriptor. |
od | An object descriptor. |
void CObjectManager::MakeShapes | ( | ) |
Make the static shapes for the things in the world. As with most physics code, this function is long and tedious, but it's important to get the details right.
|
private |
I don't know what to call it. One of the things on the left and right of the bollards at the top of the play area. This is the left one.
|
private |
I don't know what to call it. One of the things on the left and right of the bollards at the top of the play area. This is the right one.
void CObjectManager::MakeWorldEdges | ( | ) |
Make the static shapes for the world boundaries. As with most physics code, this function is long and tedious, but it's important to get the details right.
void CObjectManager::move | ( | ) |
Move all of the shapes in the dynamic and kinematic shape lists and perform collision response.
|
private |
Check whether a pair of shapes collides and make appropriate response.
pShape | Pointer to a static or kinematic shape. |
pCirc | Pointer to moving circle. |
void CObjectManager::RightFlip | ( | bool | bUp | ) |
If right flipper isn't moving up, set its rotational velocity to ROTSPEED (with the correct sign indicating direction), and play a sound.
bUp | true for up flip, false for down flip. |