![]() |
Tiled Platformer Prototype
A Basic Tiled Platformer
|
The player object. More...
#include <Player.h>


Public Member Functions | |
| CPlayer (const Vector2 &) | |
| Constructor. | |
| ~CPlayer () | |
| Destructor. | |
| void | Move () |
| Move player object. | |
| void | Draw () |
| Draw. | |
| void | SetAction (const eAction, const eDirection=eDirection::Continue) |
| Set action. | |
| const Vector2 & | GetPos () const |
| Get position. | |
| const eAction | GetAction () const |
| Get current action. | |
| const bool | IsAlive () const |
| True if alive. | |
Public Member Functions inherited from CObject | |
| CObject (eObject, eSprite, const Vector2 &) | |
| Constructor. | |
| virtual | ~CObject () |
| Destructor. | |
| void | Move () |
| Move object. | |
| void | Draw () |
| Draw object. | |
| const eObject | GetType () const |
| Get object type. | |
Private Member Functions | |
| void | CollisionResponse (const Vector2 &, float, CObject *=nullptr) |
| Collision response. | |
| void | BloodSpray (const Vector2 &) |
| Create a spray of blood. | |
Private Attributes | |
| UINT | m_nHealth = 1 |
| Health. | |
| eAction | m_eAction = eAction::Standing |
| Current action. | |
| eDirection | m_eDirection = eDirection::Right |
| Current direction. | |
| bool | m_bOnGround = false |
| True if on ground. | |
| Sage::CEventTimer * | m_pFrameEvent = nullptr |
| Frame event timer. | |
Additional Inherited Members | |
Protected Member Functions inherited from CObject | |
Protected Attributes inherited from CObject | |
| eObject | m_eObject = eObject::Unknown |
| Object type. | |
| eSprite | m_eSprite = eSprite::Saw |
| Sprite type. | |
| Vector2 | m_vPos |
| Position. | |
| float | m_fRoll = 0 |
| Roll angle. | |
| float | m_fRadius = 0 |
| Collision radius. | |
| Vector2 | m_vVelocity |
| Velocity. | |
| bool | m_bStatic = true |
| Is static (does not move). | |
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_bShowBounds = false |
| Draw bounding boxes and circles flag. | |
| static eGameState | m_eGameState = eGameState::Loading |
| Game state. | |
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 | ) |
Create and initialize a player object.
| p | Initial position of player. |
| CPlayer::~CPlayer | ( | ) |
The destructor deletes the event timer created by the constructor.
|
private |
Create a particle effect for a spray of blood.
| norm | Contact normal. |

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

| void CPlayer::Draw | ( | ) |
Draw the sprite.

| const eAction CPlayer::GetAction | ( | ) | const |
Reader function for action.

| const Vector2 & CPlayer::GetPos | ( | ) | const |
Reader function for position.

| const bool CPlayer::IsAlive | ( | ) | const |
Test whether alive.

| void CPlayer::Move | ( | ) |
Move in response to device input. The amount of motion is proportional to the frame time.

| void CPlayer::SetAction | ( | const eAction | action, |
| const eDirection | d = eDirection::Continue ) |
Set action and direction. If the new action is eAction::Dying and the current action is not eAction::Dying, then restart the frame event and play a death sound. If the new action is not eAction::Jumping or the current action is not eAction::Walking, then change the current action to the new action. If the new direction is not eDirection::Continue then change the current direction to the new direction, otherwise leave it the same.
| action | The new action. |
| d | The new direction of action, defaults to eDirection::Continue. |
