summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pacman-c++/actor.cpp17
-rw-r--r--pacman-c++/actor.h3
-rw-r--r--pacman-c++/point.cpp6
-rw-r--r--pacman-c++/sceneholder.cpp9
-rw-r--r--pacman-c++/util.cpp4
-rw-r--r--pacman-c++/util.h2
6 files changed, 26 insertions, 15 deletions
diff --git a/pacman-c++/actor.cpp b/pacman-c++/actor.cpp
index a746546..7b77851 100644
--- a/pacman-c++/actor.cpp
+++ b/pacman-c++/actor.cpp
@@ -190,7 +190,7 @@ void Actor::move(Actor::Movement direction)
190 { 190 {
191 //TODO 191 //TODO
192 qDebug() << "pause"; 192 qDebug() << "pause";
193 m_wakaPlayer->pause(); 193 //m_wakaPlayer->pause();
194 } 194 }
195 195
196 m_direction = direction; 196 m_direction = direction;
@@ -242,11 +242,20 @@ void Actor::eatingCherry()
242 AudioManager::self()->play(Sound::EatingCherry); 242 AudioManager::self()->play(Sound::EatingCherry);
243} 243}
244 244
245AudioPlayer *Actor::wakaPlayer() 245void Actor::startEating()
246{
247 if (!m_local || !m_wakaPlayer->isWorking())
248 return;
249 if (m_wakaPlayer->state() != Phonon::PlayingState)
250 m_wakaPlayer->play();
251}
252
253void Actor::stopEating()
246{ 254{
247 if (!m_local || !m_wakaPlayer->isWorking()) 255 if (!m_local || !m_wakaPlayer->isWorking())
248 return NULL; 256 return;
249 return m_wakaPlayer; 257 if (m_wakaPlayer->state() != Phonon::PausedState)
258 m_wakaPlayer->pause();
250} 259}
251 260
252unsigned int Actor::getRoundPoints() 261unsigned int Actor::getRoundPoints()
diff --git a/pacman-c++/actor.h b/pacman-c++/actor.h
index 6b6f743..794f00b 100644
--- a/pacman-c++/actor.h
+++ b/pacman-c++/actor.h
@@ -34,7 +34,8 @@ public:
34 bool isMoving(); 34 bool isMoving();
35 void die(); 35 void die();
36 void eatingCherry(); 36 void eatingCherry();
37 AudioPlayer *wakaPlayer(); 37 void startEating();
38 void stopEating();
38 39
39 unsigned int getRoundPoints(); 40 unsigned int getRoundPoints();
40 unsigned int getGamePoints(); 41 unsigned int getGamePoints();
diff --git a/pacman-c++/point.cpp b/pacman-c++/point.cpp
index 755871d..7be09c0 100644
--- a/pacman-c++/point.cpp
+++ b/pacman-c++/point.cpp
@@ -28,9 +28,5 @@ bool Point::enter(Actor *actor)
28 28
29void Point::onDie(Actor *actor) 29void Point::onDie(Actor *actor)
30{ 30{
31 AudioPlayer *player = actor->wakaPlayer(); 31 actor->startEating();
32 if (player == NULL)
33 return;
34 if (player->state() != Phonon::PlayingState)
35 player->play();
36} 32}
diff --git a/pacman-c++/sceneholder.cpp b/pacman-c++/sceneholder.cpp
index f44f767..d9e07e5 100644
--- a/pacman-c++/sceneholder.cpp
+++ b/pacman-c++/sceneholder.cpp
@@ -113,9 +113,14 @@ void SceneHolder::updateMap(const Transmission::map_t& map)
113 } 113 }
114 else 114 else
115 { 115 {
116 Actor::Movement direction = 116 Actor::Movement direction = Util::transmissionMovementToActor(
117 Util::transmissionMovementToActor(cur & Transmission::direction_mask); 117 cur & Transmission::direction_mask);
118 actor->move(direction); 118 actor->move(direction);
119 /* that's kind a hack but working right now
120 * I think that will fall on our's hat sooner or later
121 */
122 if (!(cur & Transmission::empty))
123 actor->stopEating();
119 qDebug() << "[SceneUpdate] actor moves: color=" << color 124 qDebug() << "[SceneUpdate] actor moves: color=" << color
120 << "direction=" << direction << "newpos=" << QPoint(x, y); 125 << "direction=" << direction << "newpos=" << QPoint(x, y);
121 } 126 }
diff --git a/pacman-c++/util.cpp b/pacman-c++/util.cpp
index 999c765..c60f2df 100644
--- a/pacman-c++/util.cpp
+++ b/pacman-c++/util.cpp
@@ -158,9 +158,9 @@ namespace Util
158 sendPacket(data, dataStr.length(), socket); 158 sendPacket(data, dataStr.length(), socket);
159 } 159 }
160 160
161 void sendPacket(const char *data, unsigned int length, QTcpSocket *socket) 161 void sendPacket(const char *data, int length, QTcpSocket *socket)
162 { 162 {
163 unsigned int bytesWritten = socket->write(data, length); 163 int bytesWritten = socket->write(data, length);
164 if (bytesWritten != length) 164 if (bytesWritten != length)
165 { 165 {
166 qDebug() << "[sendPacket] Not all data has been sent." 166 qDebug() << "[sendPacket] Not all data has been sent."
diff --git a/pacman-c++/util.h b/pacman-c++/util.h
index 9f7f784..e0f1264 100644
--- a/pacman-c++/util.h
+++ b/pacman-c++/util.h
@@ -23,6 +23,6 @@ namespace Util
23 23
24 // send packet with error check and flush 24 // send packet with error check and flush
25 void sendPacket(const ::google::protobuf::Message& packet, QTcpSocket *socket); 25 void sendPacket(const ::google::protobuf::Message& packet, QTcpSocket *socket);
26 void sendPacket(const char *data, unsigned int length, QTcpSocket *socket); 26 void sendPacket(const char *data, int length, QTcpSocket *socket);
27} 27}
28#endif // UTIL_H 28#endif // UTIL_H