Player
Public member functions
// Construct a new Player object
Player(Room &room, std::shared_ptr<Client> client, u_int id, short x, short y);
// Construct a new Player object
Player(Room &room, std::shared_ptr<Client> client, u_int id, const std::pair<short, short> &pos);
// Refresh the player. This method currently only refresh the missiles of the player by calling refreshMissiles()
virtual void refresh();
// Checks if any missile of the player collide with another entity (this method override the one from IEntity)
virtual bool collide(const IEntity &other) override;
// Move the player. This method checks if the player is out of the screen and if it is, it doesn't move it.
virtual void move(short dx, short dy);
// Send the player's position to all the clients in the room
virtual void sendPos();
// Fire a missile. This method checks the time between the last missile fired and the current time and if it's less than PLAYER_FIRE_TIME, it doesn't fire a missile.
virtual void fireMissile();
// Get the last move time. This method is used by the room to not move the player too fast
const std::chrono::system_clock::time_point &lastMoveTime() const;
// Set the last move time. This method is used by the room to not move the player too fast
void setLastMoveTime(const std::chrono::system_clock::time_point &lastMoveTime);
// Get the player's score
int score() const;
// Set the player's score
void setScore(int score);
// Get the player's client
std::shared_ptr<Client> client() const;