Tiled Platformer Prototype
A Basic Tiled Platformer
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 (eObject, eSprite, const Vector2 &)
 Constructor.
 
virtual ~CObject ()
 Destructor.
 
void Move ()
 Move object.
 
void Draw ()
 Draw object.
 
const eObject GetType () const
 Get object type.
 

Protected Member Functions

virtual void CollisionResponse (const Vector2 &, float, CObject *=nullptr)
 Collision response.
 

Protected Attributes

eObject m_eObject = eObject::Unknown
 Object type.
 
eSprite m_eSprite = eSprite::Saw
 Sprite type.
 
Vector2 m_vPos
 Position.
 
float m_fRoll = 0
 Roll angle.
 
float m_fRadius = 0
 Collision radius.
 
Vector2 m_vVelocity
 Velocity.
 
bool m_bStatic = true
 Is static (does not move).
 

Friends

class CObjectManager
 Object manager needs access so it can manage.
 

Additional Inherited Members

- Static Protected Attributes inherited from CCommon
static Sage::CSpriteRenderer * m_pRenderer = nullptr
 Pointer to renderer.
 
static CObjectManagerm_pObjectManager = nullptr
 Pointer to object manager.
 
static Sage::CParticleEngine2D * m_pParticleEngine = nullptr
 Pointer to particle engine.
 
static CTileManagerm_pTileManager = nullptr
 Pointer to tile manager.
 
static CPlayerm_pPlayer = nullptr
 Pointer to player character.
 
static Vector2 m_vWorldSize
 World height and width.
 
static bool m_bGodMode = false
 God mode flag.
 
static bool m_bShowBounds = false
 Draw bounding boxes and circles flag.
 
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 ( eObject obj,
eSprite spr,
const Vector2 & p )

Create and initialize an object.

Parameters
objObject type.
sprSprite type.
pInitial position.

Member Function Documentation

◆ CollisionResponse()

void CObject::CollisionResponse ( const Vector2 & norm,
float d,
CObject * pObj = nullptr )
protectedvirtual

Response to collision, which depends on whether this object and/or the colliding object is static or not. Let's call a non-static object dynamic for now. If both objects are dynamic, then both are est back by half the overlap distance along the collision normal. If one object is static and the other dynamic, then the dynamic one is set back by the full overlap distance. The fourth case (both objects are static) won't happen because static objects don't move and therefore can't collide.

Parameters
normCollision normal.
dOverlap distance.
pObjPointer to object being collided with (defaults to nullptr, which means collision with a wall).

Reimplemented in CPlayer.

Here is the caller graph for this function:

◆ Draw()

void CObject::Draw ( )

Draw the sprite.

◆ GetType()

const eObject CObject::GetType ( ) const

Reader function for the object type.

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

◆ Move()

void CObject::Move ( )

Move object an amount that depends on the frame time.