Player
The Player class represents the player in the game.
This class is derived from the ArmedEntity class and add some methods to manage the player.
Public member functions
Member functions documentation
Constructor
The constructor of the Player class.
Parameters
room
: A reference to the room in which the player is.client
: A shared pointer to the client of the player.id
: The id of the player.x
: The x position of the player.y
: The y position of the player.pos
: A pair of short containing the position of the player (x, y).
refresh
This method refreshes the player. It currently only refresh the missiles of the player by calling refreshMissiles()
collide
This method checks if any missile of the player collide with another entity (this method override the one from IEntity)
Parameters
other
: A reference to the other entity to check collision with.
Returns
A boolean which is true if the player collide with the other entity, false otherwise.
move
This method moves the player. It checks if the player is out of the screen and if it is, it doesn't move it.
Parameters
dx
: The x offset to move the player.dy
: The y offset to move the player.
sendPos
This method sends the player's position to all the clients in the room.
fireMissile
This method fires a missile. It 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.
lastMoveTime
This method returns the last move time of the player. It is used by the room to not move the player too fast.
Returns
A reference to the last move time of the player.
setLastMoveTime
This method sets the last move time of the player. It is used by the room to not move the player too fast.
Parameters
lastMoveTime
: The last move time of the player.
score
This method returns the score of the player.
Returns
The player's score.
setScore
This method sets the score of the player.
Parameters
score
: The player's score.
client
This method returns the client of the player.
Returns
A shared pointer to the client of the player.