summaryrefslogtreecommitdiffstats
path: root/pacman-c++
diff options
context:
space:
mode:
authortotycro <totycro@unknown-horizons.org>2011-04-11 13:03:40 +0200
committertotycro <totycro@unknown-horizons.org>2011-04-11 13:03:40 +0200
commitea2880702a7df079f5e8eee0280584f186c2de73 (patch)
treea509f39d1ad479d44a0babb7ebfd962e8bfe6352 /pacman-c++
parent46cba78d4017cad17550a1169c7deb7120710c2a (diff)
downloadfoop-ea2880702a7df079f5e8eee0280584f186c2de73.tar.gz
foop-ea2880702a7df079f5e8eee0280584f186c2de73.tar.bz2
foop-ea2880702a7df079f5e8eee0280584f186c2de73.zip
Added code to play the cherry sound, but doesn't work here
Diffstat (limited to 'pacman-c++')
-rw-r--r--pacman-c++/bonuspoint.cpp7
-rw-r--r--pacman-c++/bonuspoint.h1
-rw-r--r--pacman-c++/gameentity.h6
-rw-r--r--pacman-c++/point.cpp4
-rw-r--r--pacman-c++/point.h2
-rw-r--r--pacman-c++/sceneholder.cpp11
6 files changed, 29 insertions, 2 deletions
diff --git a/pacman-c++/bonuspoint.cpp b/pacman-c++/bonuspoint.cpp
index 2b5500b..a705c09 100644
--- a/pacman-c++/bonuspoint.cpp
+++ b/pacman-c++/bonuspoint.cpp
@@ -26,3 +26,10 @@ bool BonusPoint::enter(Actor* actor)
26 m_eaten = true; 26 m_eaten = true;
27 return false; 27 return false;
28} 28}
29
30void BonusPoint::onDie(Actor *actor)
31{
32 qDebug() << "here comes the cherry.. ";
33 actor->eatingCherry();
34}
35
diff --git a/pacman-c++/bonuspoint.h b/pacman-c++/bonuspoint.h
index dcf561e..222e046 100644
--- a/pacman-c++/bonuspoint.h
+++ b/pacman-c++/bonuspoint.h
@@ -12,6 +12,7 @@ public:
12 {}; 12 {};
13 13
14 virtual bool enter(Actor *actor); 14 virtual bool enter(Actor *actor);
15 virtual void onDie(Actor *actor);
15}; 16};
16 17
17#endif // BONUSPOINT_H 18#endif // BONUSPOINT_H
diff --git a/pacman-c++/gameentity.h b/pacman-c++/gameentity.h
index 2a771ee..0c0ab9c 100644
--- a/pacman-c++/gameentity.h
+++ b/pacman-c++/gameentity.h
@@ -20,8 +20,14 @@ public:
20 // returns whether this entity survives the entering 20 // returns whether this entity survives the entering
21 virtual bool enter(Actor *actor) { Q_UNUSED(actor); return true; } // default to no action/survive 21 virtual bool enter(Actor *actor) { Q_UNUSED(actor); return true; } // default to no action/survive
22 22
23 // check whether this entity is regarded as eaten
24 // (and can be removed in the next tick)
23 virtual bool eaten() { return m_eaten; } 25 virtual bool eaten() { return m_eaten; }
24 26
27 // called when an instance acctually dies for creating effects
28 virtual void onDie(Actor *actor) { Q_UNUSED(actor); };
29
30
25protected: 31protected:
26 bool m_eaten; 32 bool m_eaten;
27}; 33};
diff --git a/pacman-c++/point.cpp b/pacman-c++/point.cpp
index 05bd277..b4eae4e 100644
--- a/pacman-c++/point.cpp
+++ b/pacman-c++/point.cpp
@@ -23,3 +23,7 @@ bool Point::enter(Actor* actor)
23 m_eaten = true; 23 m_eaten = true;
24 return false; 24 return false;
25} 25}
26
27void Point::onDie(Actor* actor)
28{
29}
diff --git a/pacman-c++/point.h b/pacman-c++/point.h
index 033ca56..944764b 100644
--- a/pacman-c++/point.h
+++ b/pacman-c++/point.h
@@ -12,6 +12,8 @@ public:
12 {}; 12 {};
13 13
14 virtual bool enter(Actor *actor); 14 virtual bool enter(Actor *actor);
15
16 virtual void onDie(Actor *actor);
15}; 17};
16 18
17#endif // POINT_H 19#endif // POINT_H
diff --git a/pacman-c++/sceneholder.cpp b/pacman-c++/sceneholder.cpp
index e4429f6..c819b95 100644
--- a/pacman-c++/sceneholder.cpp
+++ b/pacman-c++/sceneholder.cpp
@@ -40,8 +40,16 @@ void SceneHolder::updateMap(const Transmission::map_t& map)
40 { 40 {
41 m_scene->removeItem(oldItem); 41 m_scene->removeItem(oldItem);
42 visualMap[x][y] = NULL; 42 visualMap[x][y] = NULL;
43 Actor *actor = NULL;
44 foreach (Actor *i, m_actors) {
45 if (CoordToMapPosition(i->pos().x(), i->pos().y()) == QPoint(x, y)) {
46 actor = i;
47 break;
48 }
49 }
50 oldItem->onDie(actor);
43 delete oldItem; 51 delete oldItem;
44 qDebug() << "deleting " << x << y; 52 //qDebug() << "deleting " << x << y;
45 } 53 }
46 } 54 }
47 55
@@ -104,7 +112,6 @@ void SceneHolder::updateMap(const Transmission::map_t& map)
104 visualMap[x][y] = item; 112 visualMap[x][y] = item;
105 if (oldItem != NULL) 113 if (oldItem != NULL)
106 { 114 {
107 oldItem->onDie();
108 m_scene->removeItem(item); 115 m_scene->removeItem(item);
109 delete oldItem; 116 delete oldItem;
110 } 117 }