![]() |
The 8-ball Pool End Game
Game Physics with Bespoke Code
|
The game object. More...
#include <Object.h>


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. | |
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 CObjectManager * | m_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. | |
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.
| CObject::CObject | ( | eSprite | t, |
| const Vector2 & | pos ) |
Create an object, given its sprite type and initial position.
| t | Type of ball. |
| pos | Initial position. |
| 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.
| a | Impulse angle. |
| m | Impulse magnitude. |

| void CObject::Draw | ( | ) |
Draw from sprite descriptor.

| 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.
| p | Pointer to a 2D particle descriptor. |

| 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.
