#ifndef GAMEENTITY_H #define GAMEENTITY_H #include "constants.h" #include "pixmapitem.h" #include class Actor; /** * Base class for entities that interact in the game */ class GameEntity : public PixmapItem { public: GameEntity(Color::Color color = Color::none, QGraphicsItem *parent = 0); GameEntity(QGraphicsItem *parent); virtual ~GameEntity() {}; /* color of entity */ virtual Color::Color color() { return m_color; } /* returns whether the actor may enter this field */ virtual bool checkEnter(Actor *) { return true; } /* performs action when this actor acctually enters * returns whether this entity survives the entering */ virtual bool enter(Actor *) { /* default to no action/survive */ return true; } /* check whether this entity is regarded as eaten * (and can be removed in the next tick) */ virtual bool eaten() { return m_eaten; } /* called when an instance acctually dies for creating effects */ virtual void onDie(Actor *) {}; protected: bool m_eaten; Color::Color m_color; }; #endif // GAMEENTITY_H