Dauphine  0.1
A platforming/stealth game in a medieval fantasy setting, developed with SDL2.
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
Player Class Reference

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_)
 
AnimationgetAnimation ()
 
CrosshairgetCrosshair ()
 
void setCrosshair (Crosshair *const crosshair)
 
BombPotiongetBombPotion ()
 
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

Animationanimation
 Current player animation. More...
 
StatePlayercurrentState
 The current state, which the player is in. More...
 
std::map< PStates, StatePlayer * > statesMap
 Map containing all possible states. More...
 
Crosshaircrosshair
 
BombPotionbombPotion
 

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

 

Detailed Description

The player entity class.

Contains all the relevant implementation relative to the player.

Constructor & Destructor Documentation

Player::Player ( const double  x_,
const double  y_,
Sprite *const  sprite_ 
)

The constructor.

Creates the player by setting the position and sprite.

Parameters
x_: position in x axis.
y_: position in y axis.
sprite_: which sprite to use.
Player::~Player ( )
virtual

The destructor.

Exits the current state and destroys all states.

Member Function Documentation

void Player::changeState ( const PStates  state_)

Sets the current game state.

See Also
StatePlayer::load
StatePlayer::unload
Parameters
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 ( )
Returns
The players current animation setting.
void Player::initializeStates ( )

Loads all the states.

Every new state implemented should be initialized here.

bool Player::isCurrentState ( const PStates  state_)
Returns
Whether the player is currently in PStates::state_ or not.
void Player::render ( const double  cameraX_,
const double  cameraY_ 
)
virtual

Renders the player.

Uses the player's sprite render method.

See Also
Sprite::render
Parameters
cameraX_: The x position of the camera.
cameraY_: The y position of the camera.

Implements Entity.

void Player::update ( const double  dt_)
virtual

Updates the player.

See Also
Player::updateInput, Player::updatePosition
Parameters
dt_: Delta time. Time elapsed between one frame and the other, independent of processing speed.

Implements Entity.

Member Data Documentation

Animation* Player::animation
private

Current player animation.

StatePlayer* Player::currentState
private

The current state, which the player is in.

std::map<PStates, StatePlayer*> Player::statesMap
private

Map containing all possible states.


The documentation for this class was generated from the following files: