The Stroop Test Game
Ian Parberry's "Introduction to Game Physics"
Public Member Functions | List of all members
CObject Class Reference

The game object. More...

#include <Object.h>

Inheritance diagram for CObject:
CObjDesc CCommon

Public Member Functions

 CObject (const CObjDesc &)
 Constructor. More...
 
 ~CObject ()
 Destructor.
 
void SetPhysicsJoint (b2Joint *)
 Set pointer to physics world joint. More...
 
const bool isCurrent () const
 Is in the current word. More...
 
void DeliverImpulse (const Vector2 &)
 Deliver random impulse. More...
 
const Vector2 GetPos () const
 
const Vector2 GetVel () const
 < Get position. More...
 
const eSprite GetSpriteType () const
 < Get velocity. More...
 
const void GetSpriteDesc (LSpriteDesc2D &) const
 Get sprite descriptor. More...
 
float GetBirthTime ()
 Get birth time. More...
 
void SetBirthTime (float)
 sGet birth time. More...
 
const eWordColor GetColor () const
 Get color. More...
 
void SetColor (eWordColor)
 Set color. More...
 
bool GetJointInfo (Vector2 &, Vector2 &)
 Get joint position and velocity. More...
 
void DestroyJoint ()
 Destroy joint. More...
 

Additional Inherited Members

- Static Protected Attributes inherited from CCommon
static b2World * m_pPhysicsWorld = nullptr
 Pointer to Box2D Physics World.
 
static CRendererm_pRenderer = nullptr
 Pointer to the Renderer.
 
static CObjectManagerm_pObjectManager = nullptr
 Pointer to the Object Manager.
 
static LParticleEngine2D * m_pParticleEngine = nullptr
 Pointer to particle engine.

 
static CVectorFieldm_pVectorField = nullptr
 Pointer to a vector field.
 
static CBubbleEnginem_pBubbleEngine = nullptr
 Pointer to a bubble engine.
 
static bool m_bDrawVectors = false
 Do we draw the vector field?
 
static bool m_bDrawPressure = false
 Do we draw the pressures from the vector field?
 
static bool m_bDrawPoints = false
 Do we draw the points from the vector field?
 
static bool m_bDrawParticles = true
 Do we draw particles?
 
static eWordColor m_eCurColor = eWordColor::Black
 Color of the current word.
 
static bool m_bTried = false
 Whether the player has tried on the current word.
 
static UINT m_nWordCnt = INITIAL_WORDCOUNT
 Number of words.
 
static UINT m_nScore = 0
 Current score, can be negatice.
 
static UINT m_nDelivered = 0
 Number of words delivered.
 
static UINT m_nExcellent = 0
 Number of words scored as excellent.
 
static UINT m_nGood = 0
 Number of words scored as excellent.
 
static UINT m_nFair = 0
 Number of words scored as excellent.
 
static UINT m_nFailed = 0
 Number of words the player got wrong.
 
static UINT m_nMissed = 0
 Number of words the player did not attempt.
 
static eGameState m_eGameState = eGameState::Instructions
 Current game state.
 
static UINT m_nCntdownNum = 0
 The number we are displaying in the countdown.
 
- Private Attributes inherited from CObjDesc
eSprite m_eSpriteType = eSprite::Size
 Sprite type.
 
b2Body * m_pBody = nullptr
 Physics World body.
 
b2Joint * m_pJoint = nullptr
 Joint in Physics World.
 
eWordColor m_eColor = eWordColor::Gray
 Sprite color;.
 
float m_fScale = 1.0f
 Image scale.
 
float m_fBirthTime = 0
 Time of creation.
 

Detailed Description

The game object.

Game objects are responsible for remembering information about themselves, in particular, their representations in Render World and Physics World.

Constructor & Destructor Documentation

◆ CObject()

CObject::CObject ( const CObjDesc d)

Constructor.

Constructor for a game object.

Parameters
dObject descriptor.

Member Function Documentation

◆ DeliverImpulse()

void CObject::DeliverImpulse ( const Vector2 &  v)

Deliver random impulse.

Deliver an impulse, assuming this object has a body in Physics World.

Parameters
vImpulse vector in Render World units.

◆ DestroyJoint()

void CObject::DestroyJoint ( )

Destroy joint.

Destroy joint, if this object has one.

◆ GetBirthTime()

float CObject::GetBirthTime ( )

Get birth time.

Reader function for the birth time.

Returns
Birth time.

◆ GetColor()

const eWordColor CObject::GetColor ( ) const

Get color.

Reader function for the color.

Returns
Color.

◆ GetJointInfo()

bool CObject::GetJointInfo ( Vector2 &  p,
Vector2 &  v 
)

Get joint position and velocity.

Get the joint's position and velocity in Render World. The values of the call-by-reference parameters are not changed if this object is bodiless.

Parameters
p[OUT] Joint position in Render World coordinates.
v[OUT] Joint velocity in Render World units.
Returns
True if this object has a body.

◆ GetPos()

const Vector2 CObject::GetPos ( ) const

Reader function for position.

Returns
Position in Render World units.

◆ GetSpriteDesc()

const void CObject::GetSpriteDesc ( LSpriteDesc2D &  d) const

Get sprite descriptor.

Construct a sprite descriptor.

Parameters
d[IN, OUT] Sprite descriptor.

◆ GetSpriteType()

const eSprite CObject::GetSpriteType ( ) const

< Get velocity.

Get sprite type.

Reader function for sprite type.

Returns
Sprite type.

◆ GetVel()

const Vector2 CObject::GetVel ( ) const

< Get position.

Reader function for velocity.

Returns
Velocity in Render World units.

◆ isCurrent()

const bool CObject::isCurrent ( ) const

Is in the current word.

A letter is part of the current word when its color is either red, green, or blue.

Returns
True if this letter is part of the current word.

◆ SetBirthTime()

void CObject::SetBirthTime ( float  t)

sGet birth time.

Parameters
tBirth time in seconds.

◆ SetColor()

void CObject::SetColor ( eWordColor  clr)

Set color.

Parameters
clrColor

◆ SetPhysicsJoint()

void CObject::SetPhysicsJoint ( b2Joint *  j)

Set pointer to physics world joint.

Set the physics joint pointer (from Physics World) of the game object.

Parameters
jPointer to the physics joint.