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


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 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. | |
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.
| CPlayer::CPlayer | ( | const Vector2 & | p, |
| float | d ) |
Create and initialize a player object.
| p | Initial position of player. |
| d | Initial orientation of player. |
| CPlayer::~CPlayer | ( | ) |
The destructor deletes the event timer created by the constructor.
|
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.
| norm | Collision normal. |
| d | Overlap distance. |
| pObj | Pointer to object being collided with (defaults to nullptr, which means collision with a wall). |
Reimplemented from CObject.

| const float CPlayer::GetRadius | ( | ) | const |
Reader function for radius.
| const bool CPlayer::IsVulnerable | ( | ) | const |
Reader function for vulnerable flag.
| void CPlayer::LookAt | ( | const Vector2 & | v | ) |
Start rotating to look at a point.
| v | Point to look at. |

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

| void CPlayer::SetMovement | ( | const eDirection | d | ) |
Set direction of movement relative to view vector. This function will be called in response to device inputs.
| d | New direction of movement. |

| 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.
| speed | Rotational speed in RPS. |

| void CPlayer::SetVulnerable | ( | ) |
Set the vulnerable flag to true to make the player vulnerable to attack.
