The Stroop Test Game
Game Physics with a 2D Physics Engine
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 (const CObjDesc &)
 Constructor.
 
 ~CObject ()
 Destructor.
 
void Draw ()
 Draw object.
 
void SetPhysicsJoint (b2Joint *)
 Set pointer to physics world joint.
 
const bool isCurrent () const
 Is in the current word.
 
void DeliverImpulse (const Vector2 &)
 Deliver random impulse.
 
const Vector2 GetPos () const
 
const Vector2 GetVel () const
 < Get position.
 
const eSprite GetSpriteType () const
 < Get velocity.
 
float GetBirthTime ()
 Get birth time.
 
void SetBirthTime (float)
 sGet birth time.
 
const eWordColor GetColor () const
 Get color.
 
void SetColor (eWordColor)
 Set color.
 
bool GetJointInfo (Vector2 &, Vector2 &)
 Get joint position and velocity.
 
void DestroyJoint ()
 Destroy joint.
 

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 renderer.
 
static CObjectManagerm_pObjectManager = nullptr
 Pointer to the object manager.
 
static Sage::CParticleEngine2D * 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 int m_nScore = 0
 Current score, can be negative.
 
static int m_nDelivered = 0
 Number of words delivered.
 
static int m_nExcellent = 0
 Number of words scored as excellent.
 
static int m_nGood = 0
 Number of words scored as excellent.
 
static int m_nFair = 0
 Number of words scored as excellent.
 
static int m_nFailed = 0
 Number of words the player got wrong.
 
static int m_nMissed = 0
 Number of words the player did not attempt.
 
static eGameState m_eGameState = eGameState::Loading
 Current game state.
 
static UINT m_nCntdownNum = 0
 The number we are displaying in the countdown.
 
static CStroopm_pStroop = nullptr
 Pointer to Stroop caricature.
 
static eDrawMode m_eDrawMode = eDrawMode::Sprites
 Draw mode.
 
- Private Attributes inherited from CObjDesc
eSprite m_eSpriteType = eSprite::Point
 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

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 for a game object.

Parameters
dObject descriptor.

Member Function Documentation

◆ DeliverImpulse()

void CObject::DeliverImpulse ( const Vector2 & v)

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

Parameters
vImpulse vector in Render World units.
Here is the call graph for this function:

◆ DestroyJoint()

void CObject::DestroyJoint ( )

Destroy joint, if this object has one.

◆ Draw()

void CObject::Draw ( )

Draw the object using its position and orientation in Physics World.

Here is the call graph for this function:

◆ GetBirthTime()

float CObject::GetBirthTime ( )

Reader function for the birth time.

Returns
Birth time.
Here is the caller graph for this function:

◆ GetColor()

const eWordColor CObject::GetColor ( ) const

Reader function for the color.

Returns
Color.
Here is the caller graph for this function:

◆ GetJointInfo()

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

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.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPos()

const Vector2 CObject::GetPos ( ) const

Reader function for position.

Returns
Position in Render World units.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSpriteType()

const eSprite CObject::GetSpriteType ( ) const

Get sprite type.

Reader function for sprite type.

Returns
Sprite type.
Here is the caller graph for this function:

◆ GetVel()

const Vector2 CObject::GetVel ( ) const

Reader function for velocity.

Returns
Velocity in Render World units.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isCurrent()

const bool CObject::isCurrent ( ) const

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.
Here is the caller graph for this function:

◆ SetBirthTime()

void CObject::SetBirthTime ( float t)
Parameters
tBirth time in seconds.

◆ SetColor()

void CObject::SetColor ( eWordColor clr)
Parameters
clrColor

◆ SetPhysicsJoint()

void CObject::SetPhysicsJoint ( b2Joint * j)

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

Parameters
jPointer to the physics joint.