IEntity
The IEntity interface is the base of all entitites in the game. The methods in this class are used by all entities to interact with the game and to interact between each other.
All methods are pure virtual and must be implemented in each entity. Here is the list of the methods and a short description of what they are supposed to do.
Public member functions
Member functions documentation
refresh
This function refreshes the entity (move, shoot, etc.). It is called by the game loop at each frame. This function must be implemented in each entity and take care of its own time management.
position
This function returns the position of the entity.
Returns
A pair of short containing the position of the entity (x, y).
id
This function returns the id of the entity.
Returns
An unsigned int containing the id of the entity.
isOutOfScreen
This function checks if the entity is out of the screen. It is used by the game loop to delete the entity if it is out of the screen.
Returns
A boolean containing true if the entity is out of the screen, false otherwise.
collide
This function checks if the entity collide with another entity. It is used by the game loop to manage the collision between entities.
Parameters
other
: A reference to the other entity to check collision with.
Returns
A boolean containing true if the entity collide with the other entity, false otherwise.
box
This function returns the bounding box of the entity. It is used by the collide
function to compare the bounging boxes.
Returns
A const reference to the bounding box of the entity.
killEntity
This function kills the entity.
getExist
This function checks if the entity exist (is alive).
Returns
A boolean containing true if the entity exist (is alive), false otherwise.
getDeletable
This function checks if the entity is deletable (is dead).
Returns
A boolean containing true if the entity is deletable (is dead), false otherwise.