File player.hpp

class Player
#include <player.hpp>

THe Player class represents the player character that the player controls.

Public Functions

Player(std::unique_ptr<Actor> actor, Room &room)

Construct from an Actor and the Room where the Player shall be contained.

void unload() const

Unload routine.

void update()

Update routine.

void draw() const

Draw routine.

void setRoom(Room &room) const

Set the Player’s current room.

Actor &getActor() const

Get the player’s actor

void moveByVelocity(Vector2 velocity)

Move the player by a certain velocity.

Vector2 getPosition() const

Get the player’s position.

void setPosition(Vector2 pos)

Set the player’s position.

Vector2 getCenterPosition() const

Get the player’s position with an ‘anchor’ in the center.

Vector2 getTilePosition() const

Get the player’s tile position.

void setTilePosition(Vector2 tilePos)

Set the player’s tile position.

Vector2 getCollisionPos() const

Get the position of the collision.

Vector2 getCollisionCenterPos() const

Get the center position of the player’s collision.

void setMovementLock(bool value)

Set whether the Player should be able to move or not.

Private Functions

void handleCollision()

Handle the collision for this Player.

void handleInteraction()

Handle the interactions for this Player.

Private Members

bool lock
Room &room

Reference to the Room that the Player is currently in.

std::unique_ptr<Actor> actor

The Actor that this Player controls.

Vector2 position

The absolute position of this Player.

float size
Vector2 velocity

The change in the player’s position.

Direction currentDirection

Current direction state of the Player.

Direction idleDirection
Rectangle interactableArea