![]() |
The Cannon Lullaby Toy
Game Physics with a 2D Physics Engine
|
The game object. More...
#include <Object.h>


Public Member Functions | |
| CObject (eSprite, b2Body *) | |
| Constructor. | |
| ~CObject () | |
| Destructor. | |
| void | draw () |
| Draw object in Render World. | |
| void | MakeCollide () |
| Unset the collision group index to enable collisions. | |
| void | SetBellRung () |
| Record that bell has been rung. | |
| const bool | GetBellRung () const |
| Get whether bell has been rung. | |
| const eSprite | GetSpriteType () const |
| Get sprite type. | |
| const Vector2 | GetPos () const |
| Get position in Render World coordinates. | |
| const float | GetSpeed () const |
| Get speed in Render World units. | |
| const XMFLOAT4 & | GetColor () const |
| Get star color. | |
| const float | GetRingTime () const |
| Get time bell was rung. | |
| const bool | EmitsStars () const |
| Get star emission status. | |
Private Attributes | |
| eSprite | m_eSpriteType = eSprite(0) |
| Sprite type. | |
| b2Body * | m_pBody = nullptr |
| Physics World body. | |
| bool | m_bHasRungBell = false |
| Whether bell has been hit by this object. | |
| float | m_fRingTime = 0 |
| Time bell was rung. | |
| XMFLOAT4 | m_f4Color |
| Color overlay. | |
Additional Inherited Members | |
Static Protected Attributes inherited from CCommon | |
| static b2World * | m_pPhysicsWorld = nullptr |
| Pointer to Box2D Physics World. | |
| static CBox2DRenderer * | m_pRenderer = nullptr |
| Pointer to Render World. | |
| static CObjectManager * | m_pObjectManager = nullptr |
| Pointer to the Object Manager. | |
| static Sage::CParticleEngine2D * | m_pFrontParticleEngine = nullptr |
| Pointer to front particle engine. | |
| static Sage::CParticleEngine2D * | m_pBackParticleEngine = nullptr |
| Pointer to front particle engine. | |
| static CCannon * | m_pCannon = nullptr |
| Pointer to a cannon. | |
| static Vector2 | m_vBellPos [NUMBELLS] = {Vector2(0.0f)} |
| Positions of bells. | |
| static float | m_fGravity = 20.0f |
| Magnitude of gravity in Render World units. | |
| static eDrawMode | m_eDrawMode = eDrawMode::Sprites |
| Draw mode. | |
Game objects are responsible for remembering information about themselves, in particular, their representations in Render World and Physics World.
| CObject::CObject | ( | eSprite | t, |
| b2Body * | b ) |
This constructor assumes that a Physics World body has already been created for this object. It then has responsibility for deleting it in its destructor.
| t | Sprite type. |
| b | Pointer to Physics World body. |
| CObject::~CObject | ( | ) |
This destructor assumes that Box2D hasn't been shut down yet.
| void CObject::draw | ( | ) |
Draw in Render World. Position and orientation must be gotten from Physics World.

| const bool CObject::EmitsStars | ( | ) | const |
Only balls that haven't rung their bell emit stars.
| const bool CObject::GetBellRung | ( | ) | const |
Reader function for the bell rung flag.
| const XMFLOAT4 & CObject::GetColor | ( | ) | const |
Reader function for the star color.
| const Vector2 CObject::GetPos | ( | ) | const |
Reader function for position in Render World.

| const float CObject::GetRingTime | ( | ) | const |
Reader function for the time that the bell was rung. No check is made whether the ring time is valid. The calling function must call GetBellRung() to fund out if it is.
| const float CObject::GetSpeed | ( | ) | const |
Reader function for speed in Render World.

| const eSprite CObject::GetSpriteType | ( | ) | const |
Reader function for sprite type.

| void CObject::MakeCollide | ( | ) |
Make ball that has rung its bell collide with other balls after half a second delay. The delay is to make sure that they get clear of their bell first so they don't collide with incoming balls.
| void CObject::SetBellRung | ( | ) |
Set the flag indicating that this object has rung its bell and record the TOI.
