The Top-Down Tiled Game Prototype
A Basic Tiled Top-Down Shooter
Loading...
Searching...
No Matches
CPlayer Class Reference

The player object. More...

#include <Player.h>

Inheritance diagram for CPlayer:
Collaboration diagram for CPlayer:

Public Member Functions

 CPlayer (const Vector2 &p, float)
 Constructor.
 
 ~CPlayer ()
 Destructor.
 
void Move ()
 Move player object.
 
void LookAt (const Vector2 &)
 Rotate towards point.
 
void SetRotSpeed (const float)
 Set rotational velocity.
 
void SetMovement (const eDirection)
 Set movement direction.
 
const float GetRadius () const
 Get radius.
 
void SetVulnerable ()
 Set the vulnerable flag.
 
const bool IsVulnerable () const
 Get the vulnerable flag.
 
- Public Member Functions inherited from CArmedObject
 CArmedObject (eObject, eSprite, const Vector2 &, float)
 Constructor.
 
virtual ~CArmedObject ()
 Destructor.
 
virtual void Draw ()
 Draw object.
 
void CreateParticle (const Sage::CParticleDesc2D &)
 
- Public Member Functions inherited from CObject
 CObject (eObject, eSprite, const Vector2 &, float=0)
 Constructor.
 
virtual ~CObject ()
 Destructor.
 
void Draw ()
 Draw object.
 
const eObject GetType () const
 Get object type.
 
const Vector2 & GetPos () const
 Get position.
 

Private Member Functions

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

Private Attributes

bool m_bVulnerable = false
 Vulnerable flag.
 
Sage::CEventTimer * m_pEndVulnerableEvent = nullptr
 End being vulnerable.
 
eDirection m_eDirection = eDirection::None
 Direction of motion.
 
Vector2 m_vDesiredLookAtPt
 Desired look-at point.
 

Additional Inherited Members

- Protected Member Functions inherited from CArmedObject
const Vector2 GetViewVector () const
 Compute view vector.
 
const Vector2 GetGunOffset () const
 Get gun offset.
 
bool RotateTowards (const Vector2 &)
 Swivel towards position.
 
void DeathFX ()
 Death special effects.
 
- Protected Member Functions inherited from CObject
- Protected Attributes inherited from CArmedObject
UINT m_nHealth = 1
 Current health.
 
float m_fRotSpeed = 0
 Rotational speed.
 
Vector2 m_vGunOffset
 Sprite gun offset.
 
Sage::CParticleEngine2D * m_pLocalParticleEngine = nullptr
 Pointer to particle engine.

 
- Protected Attributes inherited from CObject
eObject m_eObject = eObject::Unknown
 Object type.
 
eSprite m_eSprite = eSprite::Player
 Sprite type.
 
float m_fScale = 1.0f
 Scale.
 
Vector2 m_vPos
 Position.
 
float m_fRoll = 0
 Roll angle.
 
float m_fRadius = 0
 Damage bounding circle radius.
 
Vector2 m_vCenterOffset
 Sprite center offset.
 
float m_fCollisionRadius = 0.0f
 Collision radius.
 
- 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_bShowState = false
 Show NPC state flag.
 
static bool m_bShowBounds = false
 Draw bounding boxes and circles flag.
 

Detailed Description

The abstract representation of the player object. The player differs from the other objects in the game in that it moves in respond to device inputs.

Constructor & Destructor Documentation

◆ CPlayer()

CPlayer::CPlayer ( const Vector2 & p,
float d )

Create and initialize a player object.

Parameters
pInitial position of player.
dInitial orientation of player.

◆ ~CPlayer()

CPlayer::~CPlayer ( )

The destructor deletes the event timer created by the constructor.

Member Function Documentation

◆ CollisionResponse()

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

Response to collision. If the object being collided with is a bullet, then play a sound, otherwise call CObject::CollisionResponse for the default collision response.

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

Reimplemented from CObject.

Here is the call graph for this function:

◆ GetRadius()

const float CPlayer::GetRadius ( ) const

Reader function for radius.

Returns
Radius.

◆ IsVulnerable()

const bool CPlayer::IsVulnerable ( ) const

Reader function for vulnerable flag.

Returns
Vulnerable flag, true if vulnerable.

◆ LookAt()

void CPlayer::LookAt ( const Vector2 & v)

Start rotating to look at a point.

Parameters
vPoint to look at.
Here is the caller graph for this function:

◆ Move()

void CPlayer::Move ( )
virtual

Move and rotate in response to device input stored in m_eDirection. The amount of motion and rotation is proportional to the frame time. Turn off the draw attention flag if the draw attention event has been triggered. Move the audio listener to the player's new position.

Reimplemented from CArmedObject.

Here is the call graph for this function:

◆ SetMovement()

void CPlayer::SetMovement ( const eDirection d)

Set direction of movement relative to view vector. This function will be called in response to device inputs.

Parameters
dNew direction of movement.
Here is the caller graph for this function:

◆ SetRotSpeed()

void CPlayer::SetRotSpeed ( const float speed)

Set the object's rotational speed in revolutions per second. This function will be called in response to device inputs.

Parameters
speedRotational speed in RPS.
Here is the caller graph for this function:

◆ SetVulnerable()

void CPlayer::SetVulnerable ( )

Set the vulnerable flag to true to make the player vulnerable to attack.

Here is the caller graph for this function: