diff options
Diffstat (limited to 'pacman-c++/gameentity.h')
| -rw-r--r-- | pacman-c++/gameentity.h | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/pacman-c++/gameentity.h b/pacman-c++/gameentity.h index 82df438..2a771ee 100644 --- a/pacman-c++/gameentity.h +++ b/pacman-c++/gameentity.h | |||
| @@ -1,19 +1,29 @@ | |||
| 1 | #ifndef GAMEENTITY_H | 1 | #ifndef GAMEENTITY_H |
| 2 | #define GAMEENTITY_H | 2 | #define GAMEENTITY_H |
| 3 | 3 | ||
| 4 | #include <QtGlobal> | ||
| 5 | |||
| 4 | class Actor; | 6 | class Actor; |
| 5 | 7 | ||
| 6 | /** | 8 | /** |
| 7 | * Abstract base class for entities that interact in the game | 9 | * Base class for entities that interact in the game |
| 8 | */ | 10 | */ |
| 9 | class GameEntity { | 11 | class GameEntity { |
| 12 | public: | ||
| 13 | GameEntity(); | ||
| 14 | virtual ~GameEntity() {}; | ||
| 10 | 15 | ||
| 11 | // returns whether the actor may enter this field | 16 | // returns whether the actor may enter this field |
| 12 | virtual bool checkEnter(Actor *actor) = 0; | 17 | virtual bool checkEnter(Actor *actor) { Q_UNUSED(actor); return true; } // default to true |
| 13 | 18 | ||
| 14 | // performs action when this actor acctually enters | 19 | // performs action when this actor acctually enters |
| 15 | virtual void enter(Actor *actor) = 0; | 20 | // returns whether this entity survives the entering |
| 21 | virtual bool enter(Actor *actor) { Q_UNUSED(actor); return true; } // default to no action/survive | ||
| 22 | |||
| 23 | virtual bool eaten() { return m_eaten; } | ||
| 16 | 24 | ||
| 25 | protected: | ||
| 26 | bool m_eaten; | ||
| 17 | }; | 27 | }; |
| 18 | 28 | ||
| 19 | #endif // GAMEENTITY_H | 29 | #endif // GAMEENTITY_H |
