![]() |
Dauphine
0.1
A platforming/stealth game in a medieval fantasy setting, developed with SDL2.
|
The player entity class. More...
#include <Player.h>
Public Types | |
| enum | PStates : uint8_t { IDLE = 0, MOVING, AERIAL, ROLLING, CROUCHING, AIMING } |
| All possible player states. | |
Public Member Functions | |
| Player (const double x_, const double y_, Sprite *const sprite_) | |
| The constructor. More... | |
| virtual | ~Player () |
| The destructor. More... | |
| virtual void | update (const double dt_) |
| Updates the player. More... | |
| virtual void | render (const double cameraX_, const double cameraY_) |
| Renders the player. More... | |
| void | initializeStates () |
| Loads all the states. More... | |
| void | destroyStates () |
| Deletes all the loaded states. More... | |
| void | changeState (const PStates state_) |
| Sets the current game state. More... | |
| bool | isCurrentState (const PStates state_) |
| Animation * | getAnimation () |
| Crosshair * | getCrosshair () |
| void | setCrosshair (Crosshair *const crosshair) |
| BombPotion * | getBombPotion () |
| void | setBombPotion (BombPotion *const bombPotion) |
Public Member Functions inherited from DynamicEntity | |
| DynamicEntity (const double x_, const double y_, Sprite *const sprite_) | |
| The constructor. More... | |
| virtual | ~DynamicEntity () |
| The destructor. | |
| virtual void | jump () |
| virtual void | applyGravity () |
| virtual void | move (const bool movingLeft_, const bool movingRight_) |
| virtual void | slowVx () |
| virtual void | roll () |
| virtual void | aim (Crosshair *const crosshair, double direction) |
| virtual void | useBombPotion (BombPotion *const bombPotion, const int strength, const int distance) |
| virtual void | setLevelWH (const unsigned int width_, const unsigned int height_) |
| virtual void | setCollisionRects (const std::vector< SDL_Rect > &collisionRects_) |
Public Member Functions inherited from Entity | |
| virtual | ~Entity () |
| The destructor. | |
| unsigned int | getWidth () |
| unsigned int | getHeight () |
| SDL_Rect & | getAnimationClip () |
Private Member Functions | |
| virtual void | handleCollision (std::array< bool, CollisionSide::SOLID_TOTAL > detections_) |
| Handles the collision. | |
Private Attributes | |
| Animation * | animation |
| Current player animation. More... | |
| StatePlayer * | currentState |
| The current state, which the player is in. More... | |
| std::map< PStates, StatePlayer * > | statesMap |
| Map containing all possible states. More... | |
| Crosshair * | crosshair |
| BombPotion * | bombPotion |
Additional Inherited Members | |
Public Attributes inherited from DynamicEntity | |
| double | vx |
| The dynamic entity's speed on the x axis. More... | |
| double | vy |
| The dynamic entity's speed on the x axis. More... | |
| double | speed |
| Speed that moves dynamic entity on input. More... | |
| double | maxSpeed |
| Dynamic entity max speed. More... | |
| bool | isGrounded |
| Check for if the dynamic entity is on the ground. More... | |
Protected Member Functions inherited from DynamicEntity | |
| virtual void | updatePosition (const double dt_) |
| Updates the position of the dynamic entity Update is based on what input was recieved, and the players velocity. More... | |
| std::array< bool, CollisionSide::SOLID_TOTAL > | detectCollision () |
Protected Attributes inherited from DynamicEntity | |
| unsigned int | levelW |
| The width of the level. More... | |
| unsigned int | levelH |
| The height of the level. More... | |
| std::vector< SDL_Rect > | collisionRects |
The SDL_Rects containing collidable tiles positions. More... | |
The player entity class.
Contains all the relevant implementation relative to the player.
| Player::Player | ( | const double | x_, |
| const double | y_, | ||
| Sprite *const | sprite_ | ||
| ) |
The constructor.
Creates the player by setting the position and sprite.
| x_ | : position in x axis. |
| y_ | : position in y axis. |
| sprite_ | : which sprite to use. |
|
virtual |
The destructor.
Exits the current state and destroys all states.
| void Player::changeState | ( | const PStates | state_) |
Sets the current game state.
| state_ | : The state you want to be changed into. All states are inside Player. |
| void Player::destroyStates | ( | ) |
Deletes all the loaded states.
Every new state implemented should be deleted here.
| Animation * Player::getAnimation | ( | ) |
| void Player::initializeStates | ( | ) |
Loads all the states.
Every new state implemented should be initialized here.
| bool Player::isCurrentState | ( | const PStates | state_) |
|
virtual |
Renders the player.
Uses the player's sprite render method.
| cameraX_ | : The x position of the camera. |
| cameraY_ | : The y position of the camera. |
Implements Entity.
|
virtual |
Updates the player.
| dt_ | : Delta time. Time elapsed between one frame and the other, independent of processing speed. |
Implements Entity.
|
private |
Current player animation.
|
private |
The current state, which the player is in.
|
private |
Map containing all possible states.
1.8.4