Top-down Shooter With Death
A Top-Down Shooter in Which Characters Die
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
CObject Class Reference

The game object. More...

#include <Object.h>

Inheritance diagram for CObject:
CCommon CBullet CPlayer CTurret

Public Member Functions

 CObject (eSprite, const Vector2 &)
 Constructor. More...
 
virtual ~CObject ()
 Destructor.
 
void move ()
 Move object. More...
 
void draw ()
 Draw object. More...
 
const bool isBullet () const
 Is a bullet. More...
 

Protected Member Functions

virtual void CollisionResponse (const Vector2 &, float, CObject *=nullptr)
 Collision response. More...
 
virtual void DeathFX ()
 Death special effects. More...
 
const Vector2 GetViewVector () const
 Compute view vector. More...
 

Protected Attributes

float m_fRadius = 0
 Bounding circle radius.
 
float m_fSpeed = 0
 Speed.
 
float m_fRotSpeed = 0
 Rotational speed.
 
Vector2 m_vVelocity
 Velocity.
 
bool m_bStatic = true
 Is static (does not move).
 
bool m_bIsTarget = true
 Is a target.
 
bool m_bIsBullet = false
 Is a bullet.
 
LEventTimer * m_pGunFireEvent = nullptr
 Gun fire event.
 

Friends

class CObjectManager
 Object manager needs access so it can manage.
 

Additional Inherited Members

- Static Protected Attributes inherited from CCommon
static LSpriteRenderer * m_pRenderer = nullptr
 Pointer to renderer.
 
static CObjectManagerm_pObjectManager = nullptr
 Pointer to object manager.
 
static LParticleEngine2D * m_pParticleEngine = nullptr
 Pointer to particle engine.
 
static bool m_bGodMode = false
 God mode flag.
 
static Vector2 m_vWorldSize = Vector2::Zero
 World height and width.
 
static CPlayerm_pPlayer = nullptr
 Pointer to player character.
 

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. This class must contain public member functions move() and draw() to move and draw the object, respectively.

Constructor & Destructor Documentation

◆ CObject()

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

Create and initialize an object given its sprite type and initial position.

Parameters
tType of sprite.
pInitial position of object.

Member Function Documentation

◆ CollisionResponse()

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

Response to collision. Move back the overlap distance along the collision normal.

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

Reimplemented in CPlayer, CTurret, and CBullet.

◆ DeathFX()

void CObject::DeathFX ( )
protectedvirtual

Create a particle effect to mark the death of the object. This function is a stub intended to be overridden by various object classes derived from this class.

Reimplemented in CPlayer, CTurret, and CBullet.

◆ draw()

void CObject::draw ( )

Ask the renderer to draw the sprite described in the sprite descriptor. Note that CObject is derived from LBaseObject which is inherited from LSpriteDesc2D. Therefore LSpriteRenderer::Draw(const LSpriteDesc2D*) will accept this as a parameter, automatically down-casting it from CObject* to LSpriteDesc2D*, effectively drawing the object from its sprite descriptor.

◆ GetViewVector()

const Vector2 CObject::GetViewVector ( ) const
protected

Compute the view vector from the object orientation.

Returns
The view vector.

◆ isBullet()

const bool CObject::isBullet ( ) const

Reader function for bullet flag.

Returns
true if a bullet.

◆ move()

void CObject::move ( )

Move object an amount that depends on its velocity and the frame time.