The 8-ball Pool End 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 (eSprite t, const Vector2 &p)
 Constructor.
 
 ~CObject ()
 Destructor.
 
void Move ()
 Move object.
 
void Draw ()
 Draw object.
 
void DropParticle (Sage::CParticleDesc2D *)
 Drop a particle.
 
void DeliverImpulse (const float, const float)
 Deliver an impulse.
 

Private Attributes

Sage::CSpriteDesc2D * m_pSpriteDesc
 Pointer to sprite descriptor.
 
Vector2 m_vPos
 Position.
 
Vector2 m_vOldPos
 Previous position. Only needed for Step Mode.
 
Vector2 m_vVel
 Current velocity.
 
float m_fRadius = 0.0f
 Radius.
 
bool m_bInPocket = false
 Whether currently in a pocket.
 

Friends

class CObjectManager
 Object manager needs access so it can manage.
 

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 Sage::CParticleEngine2D * m_pParticleEngine = nullptr
 Pointer to particle engine.
 
static bool m_bShowCollisions = false
 Show ball positions at TOI.
 
static bool m_bStepMode = false
 Is in step mode.
 
static bool m_bStep = false
 Step flag.
 
static float m_fXMargin = 78.0f
 Horizontal margin.
 
static float m_fYMargin = 64.0f
 Vertical margin.
 
static Vector2 m_vMargin = Vector2(m_fXMargin, m_fYMargin)
 Margins.
 
static Vector2 m_vTopLPocket = Vector2(71, 478)
 Position of top left pocket.
 
static Vector2 m_vTopRPocket = Vector2(955, 478)
 Position of top right pocket.
 
static Vector2 m_vTopCPocket = Vector2(514, 478)
 Position of top center pocket.
 
static Vector2 m_vBotLPocket = Vector2(71, 53)
 Position of bottom left pocket.
 
static Vector2 m_vBotRPocket = Vector2(955, 53)
 Position of bottom right pocket.
 
static Vector2 m_vBotCPocket = Vector2(514, 48)
 Position of bottom center pocket.
 

Detailed Description

The abstract representation of an object. CObjectManager is a friend of this class so that it can access any private members as needed to manage the objects without the need for reader and set functions for each private or protected member variable.

Constructor & Destructor Documentation

◆ CObject()

CObject::CObject ( eSprite t,
const Vector2 & pos )

Create an object, given its sprite type and initial position.

Parameters
tType of ball.
posInitial position.

Member Function Documentation

◆ DeliverImpulse()

void CObject::DeliverImpulse ( const float a,
const float m )

React to an impulse of a given angle and magnitude. The velocity vector is instantaneously changed; no need to faff about with forces applied over time.

Parameters
aImpulse angle.
mImpulse magnitude.
Here is the caller graph for this function:

◆ Draw()

void CObject::Draw ( )

Draw from sprite descriptor.

Here is the caller graph for this function:

◆ DropParticle()

void CObject::DropParticle ( Sage::CParticleDesc2D * p)

Drop a particle using the back particle engine provided the object has actually moved in the last frame. This is intended to be used in Step Mode.

Parameters
pPointer to a 2D particle descriptor.
Here is the caller graph for this function:

◆ Move()

void CObject::Move ( )

Move using Euler Integration, applying a constant amount of friction. Stop if the velocity is sufficiently small. Exactly what constitutes "sufficiently small" is hard-coded.

Here is the caller graph for this function: