![]() |
The Pinball Game
Game Physics with Bespoke Code
|
The game object. More...
#include <Object.h>


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 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. | |
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.
| CObject::CObject | ( | Shapes::CShape * | p, |
| const CObjDesc & | d ) |
Constructor.
| p | Pointer to a shape. |
| d | Pointer to an object descriptor. |
| 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.
| const Shapes::CAabb2D & CObject::GetAABB | ( | ) | const |
Reader function for the object's AABB. It gets this by querying the object's shape's AABB.
| 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.
| Shapes::CShape * CObject::GetShape | ( | ) | const |
Reader function for the object's shape.
| void CObject::Update | ( | ) |
Update object setting from its shape.