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
CTurret Class Reference

The turret object. More...

#include <Turret.h>

Inheritance diagram for CTurret:
CObject CCommon

Public Member Functions

 CTurret (const Vector2 &p)
 Constructor. More...
 
virtual void move ()
 Move turret. 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

void RotateTowards (const Vector2 &)
 Swivel towards position. More...
 
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 = 8
 Maximum health.
 
UINT m_nHealth = m_nMaxHealth
 Current health.
 
- 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

CTurret is the abstract representation of a turret object.

Constructor & Destructor Documentation

◆ CTurret()

CTurret::CTurret ( const Vector2 &  p)

Create and initialize a turret object given its position.

Parameters
pPosition of turret.

Member Function Documentation

◆ CollisionResponse()

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

Response to collision.

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 CTurret::DeathFX ( )
protectedvirtual

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

Reimplemented from CObject.

◆ move()

void CTurret::move ( )
virtual

Rotate the turret and fire the gun at at the closest available target if there is one, and rotate the turret at a constant speed otherwise.

◆ RotateTowards()

void CTurret::RotateTowards ( const Vector2 &  pos)
protected

Rotate the turrent towards a point and file the gun if it is facing sufficiently close to it.

Parameters
posTarget point.