The Pinball Game
Ian Parberry's "Introduction to Game Physics"
Public Member Functions | Private Attributes | Friends | List of all members
CObject Class Reference

The game object. More...

#include <Object.h>

Inheritance diagram for CObject:
CCommon

Public Member Functions

 CObject (CShape *, const CObjDesc &)
 Constructor.
 
void Update ()
 Update object.
 
void DrawOutline ()
 Draw outline. More...
 
const CAabb2D & GetAABB () const
 Get AABB. More...
 
CShape * GetShape () const
 Get pointer to shape. More...
 
const eMotion GetMotionType () const
 Get motion type. More...
 

Private Attributes

eSprite m_eUnlitSprite = eSprite::Size
 Unlit sprite.
 
eSprite m_eLitSprite = eSprite::Size
 Unlit sprite.
 
Vector2 m_vSpriteOffset
 Sprite offset in local coordinates.
 
CShape * m_pShape = nullptr
 Pointer to shape.

 
bool m_bRecentHit = false
 Was hit recently.
 
float m_fLastHitTime = 0
 Time of last hit.
 
UINT m_nScore = 0
 Score for collision.
 
eSound m_eSound = eSound::Size
 Collision sound.
 

Friends

class CObjectManager
 

Additional Inherited Members

- Static Protected Attributes inherited from CCommon
static CRendererm_pRenderer = nullptr
 Pointer to the renderer.
 
static CObjectManagerm_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.
 

Detailed Description

CObject is the abstract representation of an object.

Member Function Documentation

◆ DrawOutline()

void CObject::DrawOutline ( )

Draw only the outline of the object's shape. This is reasonably cheap for line segments but hideously expensive for circles and arcs because it laboriously constructs the curve by drawing very short lines. Ideally I should put it into the pixel shader but I can't be bothered. This is good enough for now.

◆ GetAABB()

const CAabb2D & CObject::GetAABB ( ) const

Reader function for the object's AABB. It gets this by querying the oblect's shape's AABB.

Returns
The object's AABB.

◆ GetMotionType()

const eMotion CObject::GetMotionType ( ) const

Reader function for the object's motion type. It gets this by querying the object's shape's motion type.

Returns
The object's motion type.

◆ GetShape()

CShape * CObject::GetShape ( ) const

Reader function for the object's shape.

Returns
A pointer to the object's shape.