![]() |
The Top-Down Tiled Game Prototype
A Basic Tiled Top-Down Shooter
|
The armed object. More...
#include <ArmedObject.h>


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 CObjectManager * | m_pObjectManager = nullptr |
| Pointer to object manager. | |
| static Sage::CParticleEngine2D * | m_pParticleEngine = nullptr |
| Pointer to particle engine. | |
| static CTileManager * | m_pTileManager = nullptr |
| Pointer to tile manager. | |
| static CPlayer * | m_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. | |
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.
Create and initialize an object.
| obj | Object type. |
| spr | Sprite type. |
| p | Initial position. |
| d | Initial orientation. |
| void CArmedObject::CreateParticle | ( | const Sage::CParticleDesc2D & | d | ) |
Create a local particle.
| d | A particle descriptor. |
|
protected |
Perform a particle effect to mark death.

|
virtual |
Draw the sprite offset by the center offset.
Reimplemented in CGuard.
|
protected |
Get the rotated vector offset from the center of the sprite to the gun.

|
protected |
Compute the view vector from the object orientation.

|
virtual |
|
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.
| pos | Target point. |
