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

The player object. More...

#include <Player.h>

Inheritance diagram for CPlayer:
CObject CCommon

Public Member Functions

 CPlayer (const Vector2 &p)
 Constructor. More...
 
virtual void move ()
 Move player object. More...
 
void SetSpeed (const float speed)
 Set speed. More...
 
void SetRotSpeed (const float speed)
 Set rotational velocity. More...
 
void StrafeLeft ()
 Strafe left. More...
 
void StrafeRight ()
 Strafe right. More...
 
void StrafeBack ()
 Strafe back. More...
 
const Vector2 & GetPos () const
 Get position. More...
 
- Public Member Functions inherited from CObject
 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...
 
- Protected Member Functions inherited from CObject
const Vector2 GetViewVector () const
 Compute view vector. More...
 

Protected Attributes

const UINT m_nMaxHealth = 12
 Maximum health.
 
UINT m_nHealth = m_nMaxHealth
 Current health.
 
bool m_bStrafeLeft = false
 Strafe left.
 
bool m_bStrafeRight = false
 Strafe right.
 
bool m_bStrafeBack = false
 Strafe back.
 
- Protected Attributes inherited from CObject
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.
 

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 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)

Create and initialize an player object given its initial position.

Parameters
pInitial position of player.

Member Function Documentation

◆ CollisionResponse()

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

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.

◆ DeathFX()

void CPlayer::DeathFX ( )
protectedvirtual

Perform a particle effect to mark the death of the player.

Reimplemented from CObject.

◆ GetPos()

const Vector2 & CPlayer::GetPos ( ) const

Reader function for position.

Returns
Position.

◆ move()

void CPlayer::move ( )
virtual

Move and rotate in response to device input. The amount of motion and rotation speed is proportional to the frame time.

◆ 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.

◆ SetSpeed()

void CPlayer::SetSpeed ( const float  speed)

Set the object's speed, assuming that the object moves in the direction of its view vector. This function will be called in response to device inputs.

Parameters
speedSpeed.

◆ StrafeBack()

void CPlayer::StrafeBack ( )

Set the strafe back flag. This function will be called in response to device inputs.

◆ StrafeLeft()

void CPlayer::StrafeLeft ( )

Set the strafe left flag. This function will be called in response to device inputs.

◆ StrafeRight()

void CPlayer::StrafeRight ( )

Set the strafe right flag. This function will be called in response to device inputs.