Ned's Turkey Farm
A Simple 2.5D Side Scroller
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 ()
 Default constructor.
 
 CObject (eSprite, const Vector3 &)
 Constructor.
 
virtual ~CObject ()
 Destructor.
 
virtual void Move ()
 Move me.
 
void Kill ()
 Kill the object.
 
bool TooOld ()
 Kill me.
 
void GetRenderList (std::vector< Sage::CSpriteDesc3D > &)
 Get render list.
 
const Vector3 & GetPos () const
 Get position.
 
const Vector3 & GetVel () const
 Get velocity.
 
const float GetRoll () const
 Get roll angle.
 
const eSprite GetType () const
 Get sprite type.
 
virtual void SetVel (const Vector3 &)
 Set velocity.
 
virtual void SetRoll (float)
 Set roll angle.
 
void SetRotSpeed (float)
 Set roll speed.
 
void SetLifeTime (float)
 Set lifetime.
 
- Public Member Functions inherited from CCommon
float Wrap (float)
 Wrap horizontal distance.
 

Protected Attributes

Sage::CSpriteDesc3D * m_pSpriteDesc = nullptr
 Pointer to sprite descriptor.
 
Vector3 m_vVel = Vector3::Zero
 Velocity.
 
float m_fRollSpeed = 0.0f
 Roll speed in revs per second.
 
float m_fFrameTimer = 0.0f
 Last time the frame was changed.
 
float m_fFrameInterval = 0.1f
 Interval between frames.
 
float m_fBirthTime = 0.0f
 Time of creation.
 
float m_fLifeTime = FLT_MAX
 Time that object lives.
 
Sage::CParticleEngine3D * m_pParticleEngine = nullptr
 Pointer to a particle engine.
 

Friends

class CObjectManager
 

Additional Inherited Members

- Static Protected Attributes inherited from CCommon
static CRendererm_pRenderer = nullptr
 Pointer to the renderer.
 
static CObjectManagerm_pObjectManager = nullptr
 Pointer to the object manager.
 
static CPlaneObjectm_pPlayer = nullptr
 Pointer to player character.
 
static float m_fWorldScale = 2.0f
 World scale.
 
static Vector3 m_vCellSize = Vector3::Zero
 Cell size.
 
static UINT m_nNumCells = 3
 Number of cells.
 
static float m_fWorldWidth = 0.0f
 World width.
 
static eDrawMode m_eDrawMode = eDrawMode::Playing
 Draw mode.
 
static eGameState m_eGameState = eGameState::Loading
 Game state.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ CObject()

CObject::CObject ( eSprite t,
const Vector3 & p )

Constructor.

Parameters
tType of sprite.
pInitial position of object.

Member Function Documentation

◆ GetPos()

const Vector3 & CObject::GetPos ( ) const

Reader function for position.

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

◆ GetRenderList()

void CObject::GetRenderList ( std::vector< Sage::CSpriteDesc3D > & renderlist)

Append the render list for the object and its particle engine.

Parameters
renderlist[IN, OUT] Render list to append to.

◆ GetRoll()

const float CObject::GetRoll ( ) const

Reader function for roll.

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

◆ GetType()

const eSprite CObject::GetType ( ) const

Reader function for the sprite type.

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

◆ GetVel()

const Vector3 & CObject::GetVel ( ) const

Reader function for velocity.

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

◆ Move()

void CObject::Move ( )
virtual

Update the position of the object and the particles in its particle engine using velocity and time. Rotate it using its roll speed and time. Change the current frame using its frame interval and time.

Reimplemented in CCrowObject, CDeadCrowObject, CHouseObject, and CPlaneObject.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetLifeTime()

void CObject::SetLifeTime ( float t)

Writer function for the lifetime. Objects die when this much time has elapsed since their birth time.

Parameters
tNew lifetime.
Here is the caller graph for this function:

◆ SetRoll()

void CObject::SetRoll ( float angle)
virtual

Writer function for roll.

Parameters
angleNew roll angle in radians.

Reimplemented in CPlaneObject.

Here is the caller graph for this function:

◆ SetRotSpeed()

void CObject::SetRotSpeed ( float rps)

Writer function for roll speed.

Parameters
rpsRevolutions per second.
Here is the caller graph for this function:

◆ SetVel()

void CObject::SetVel ( const Vector3 & v)
virtual

Writer function for the velocity.

Parameters
vNew velocity.

Reimplemented in CPlaneObject.

Here is the caller graph for this function:

◆ TooOld()

bool CObject::TooOld ( )

Died of old age.

An object is too old if the time elapsed since it was born is greater than or equal to its lifetime.

Returns
true If object has lived out its lifetime.
Here is the caller graph for this function: