The Pinball Game
Game Physics with Bespoke Code
Loading...
Searching...
No Matches
CObject Class Reference

The game object. More...

#include <Object.h>

Inheritance diagram for CObject:
Collaboration diagram for CObject:

Public Member Functions

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

Private Attributes

eSprite m_eUnlitSprite = eSprite::None
 Unlit sprite.
 
eSprite m_eLitSprite = eSprite::None
 Unlit sprite.
 
Vector2 m_vSpriteOffset
 Sprite offset in local coordinates.
 
eSound m_eSound = eSound::None
 Collision sound.
 
Shapes::CShape * m_pShape = nullptr
 Pointer to shape.

 
bool m_bRecentHit = false
 Was hit recently.
 
float m_fLastHitTime = 0.0f
 Time of last hit.
 
UINT m_nScore = 0
 Score for collision.
 

Friends

class CObjectManager
 

Additional Inherited Members

- Static Protected Attributes inherited from CCommon
static Sage::CSpriteRenderer * m_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. Notice that CObject has no move or draw functions. Moving and drawing is now handled by CShape.

Constructor & Destructor Documentation

◆ CObject()

CObject::CObject ( Shapes::CShape * p,
const CObjDesc & d )

Constructor.

Parameters
pPointer to a shape.
dPointer to an object descriptor.

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 a pixel shader but I can't be bothered. This is good enough for now.

◆ GetAABB()

const Shapes::CAabb2D & CObject::GetAABB ( ) const

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

Returns
The object's AABB.

◆ GetMotionType()

const Shapes::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()

Shapes::CShape * CObject::GetShape ( ) const

Reader function for the object's shape.

Returns
A pointer to the object's shape.

◆ Update()

void CObject::Update ( )

Update object setting from its shape.