summaryrefslogtreecommitdiffstats
path: root/pacman-c++/gameentity.h
diff options
context:
space:
mode:
Diffstat (limited to 'pacman-c++/gameentity.h')
-rw-r--r--pacman-c++/gameentity.h47
1 files changed, 31 insertions, 16 deletions
diff --git a/pacman-c++/gameentity.h b/pacman-c++/gameentity.h
index 0c0ab9c..afa3aba 100644
--- a/pacman-c++/gameentity.h
+++ b/pacman-c++/gameentity.h
@@ -8,24 +8,39 @@ class Actor;
8/** 8/**
9 * Base class for entities that interact in the game 9 * Base class for entities that interact in the game
10 */ 10 */
11class GameEntity { 11class GameEntity
12{
12public: 13public:
13 GameEntity(); 14 GameEntity();
14 virtual ~GameEntity() {}; 15 virtual ~GameEntity()
15 16 {};
16 // returns whether the actor may enter this field 17
17 virtual bool checkEnter(Actor *actor) { Q_UNUSED(actor); return true; } // default to true 18 /* returns whether the actor may enter this field */
18 19 virtual bool checkEnter(Actor *)
19 // performs action when this actor acctually enters 20 {
20 // returns whether this entity survives the entering 21 return true;
21 virtual bool enter(Actor *actor) { Q_UNUSED(actor); return true; } // default to no action/survive 22 }
22 23
23 // check whether this entity is regarded as eaten 24 /* performs action when this actor acctually enters
24 // (and can be removed in the next tick) 25 * returns whether this entity survives the entering
25 virtual bool eaten() { return m_eaten; } 26 */
26 27 virtual bool enter(Actor *)
27 // called when an instance acctually dies for creating effects 28 {
28 virtual void onDie(Actor *actor) { Q_UNUSED(actor); }; 29 /* default to no action/survive */
30 return true;
31 }
32
33 /* check whether this entity is regarded as eaten
34 * (and can be removed in the next tick)
35 */
36 virtual bool eaten()
37 {
38 return m_eaten;
39 }
40
41 /* called when an instance acctually dies for creating effects */
42 virtual void onDie(Actor *)
43 {};
29 44
30 45
31protected: 46protected: