You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
853 B
C++
47 lines
853 B
C++
#ifndef ENTITY_H
|
|
#define ENTITY_H
|
|
|
|
using coordinate = unsigned int;
|
|
|
|
/// Interface representing entity which can be placed on the map
|
|
class Entity
|
|
{
|
|
protected:
|
|
coordinate pos_x, pos_y;
|
|
|
|
public:
|
|
Entity(coordinate _x = 0, coordinate _y = 0) :
|
|
pos_x(_x), pos_y(_y)
|
|
{}
|
|
|
|
virtual ~Entity() = 0;
|
|
|
|
/// Get current Entity position
|
|
void position(coordinate &x, coordinate &y) const noexcept
|
|
{
|
|
x = pos_x;
|
|
y = pos_y;
|
|
}
|
|
|
|
/// Set Entity position explicitly
|
|
void setPosition(coordinate x, coordinate y)
|
|
{
|
|
pos_x = x;
|
|
pos_y = y;
|
|
}
|
|
|
|
/// Get current x of the Entity position
|
|
coordinate x() const noexcept
|
|
{
|
|
return pos_x;
|
|
}
|
|
|
|
/// Get current y of the Entity position
|
|
coordinate y() const noexcept
|
|
{
|
|
return pos_y;
|
|
}
|
|
};
|
|
|
|
#endif // ENTITY_H
|