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

The armed object. More...

#include <ArmedObject.h>

Inheritance diagram for CArmedObject:
Collaboration diagram for CArmedObject:

Public Member Functions

 CArmedObject (eObject, eSprite, const Vector2 &, float)
 Constructor.
 
virtual ~CArmedObject ()
 Destructor.
 
virtual void Move ()
 Move object.
 
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.
 

Protected Member Functions

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
virtual void CollisionResponse (const Vector2 &, float, CObject *=nullptr)
 Collision response.
 

Protected Attributes

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.
 

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_bShowState = false
 Show NPC state flag.
 
static bool m_bShowBounds = false
 Draw bounding boxes and circles flag.
 

Detailed Description

An armed object, that is, an object that has a gun. This class adds to CObject some basic functionality needed to manage a gun, including rotation to face a target and locating the end of the gun barrel.

Constructor & Destructor Documentation

◆ CArmedObject()

CArmedObject::CArmedObject ( eObject obj,
eSprite spr,
const Vector2 & p,
float d )

Create and initialize an object.

Parameters
objObject type.
sprSprite type.
pInitial position.
dInitial orientation.

Member Function Documentation

◆ CreateParticle()

void CArmedObject::CreateParticle ( const Sage::CParticleDesc2D & d)

Create a local particle.

Parameters
dA particle descriptor.

◆ DeathFX()

void CArmedObject::DeathFX ( )
protected

Perform a particle effect to mark death.

Here is the caller graph for this function:

◆ Draw()

void CArmedObject::Draw ( )
virtual

Draw the sprite offset by the center offset.

Reimplemented in CGuard.

◆ GetGunOffset()

const Vector2 CArmedObject::GetGunOffset ( ) const
protected

Get the rotated vector offset from the center of the sprite to the gun.

Returns
The gun offset.
Here is the caller graph for this function:

◆ GetViewVector()

const Vector2 CArmedObject::GetViewVector ( ) const
protected

Compute the view vector from the object orientation.

Returns
The view vector.
Here is the caller graph for this function:

◆ Move()

void CArmedObject::Move ( )
virtual

Move particle effects relative to the end of the gun barrel and performs a step of the particle engine.

Reimplemented in CGuard, and CPlayer.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RotateTowards()

bool CArmedObject::RotateTowards ( const Vector2 & pos)
protected

Rotate towards a target point and determine whether sufficiently close to looking directly at it. It first computes theta, the orientation of the vector from the center of the object to the target, then a value diff equal to the difference between the object orientation CArmedObject::m_fRoll and theta. It then computes a positive tracking speed fTrackingSpeed that is faster for larger values of diff, then uses this to compute an angle change fAngleDelta proportional to the tracking speed and frame time. Its rotation speed CArmedObject::m_fRotSpeed is set to plus or minus fTrackingSpeed depending on whether diff is less than -fAngleDelta or greater than fAngleDelta, respectively, and otherwise m_fRoll snaps to theta (the return value will later be true in this case and false otherwise). CArmedObject::m_fRoll is then incremented by an amount proportional to CArmedObject::m_fRotSpeed times the frame time.

Parameters
posTarget point.
Returns
true if pointing close to target point.
Here is the caller graph for this function: