LittleMonster
LittleMonster
The Little monster class represents a little monster in the game that fires missiles and moves straight left.
This class is derived from the ArmedEntity class and implements some of its methods.
Public member functions
// Construct a new Little Monster object
LittleMonster(Room &room, u_int id, short x, short y);
// Construct a new Little Monster object
LittleMonster(Room &room, u_int id, const std::pair<short, short> &pos);
// Refresh the entity
virtual void refresh();
// Check if the entity collide with another entity
virtual bool collide(const IEntity &other) override;
Member functions documentation
Constructor
The constructor of the LittleMonster class.
LittleMonster(Room &room, u_int id, short x, short y);
LittleMonster(Room &room, u_int id, const std::pair<short, short> &pos);
Parameters
room
: A reference to the room in which the little monster is.id
: The id of the little monster.x
: The x position of the little monster.y
: The y position of the little monster.pos
: A pair of short containing the position of the little monster (x, y).
refresh
This function refreshes the little monster by doing the following:
Refresh the missiles
Fire missile every ENEMY_FIRE_TIME
Move itself every ENEMY_MOVE_TIME and send the new position to all clients
virtual void refresh();
collide
This function checks if the little monster or any of its missiles collide with another entity.
virtual bool collide(const IEntity &other) override;
Parameters
other
: A reference to the entity to check collision with.
Returns
True if the little monster or any of its missiles collide with the other entity, false otherwise.