diff options
| author | manuel <manuel@mausz.at> | 2011-04-25 14:39:00 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2011-04-25 14:39:00 +0200 |
| commit | 41a31420cf091aeb4e986503387855d41e550106 (patch) | |
| tree | ffbe0be5f9630a0bab2deb0b5df37c174bf40db1 /pacman-c++/actor.cpp | |
| parent | bbd2a69a962d15f74a4afcb7b66462eac9fa5008 (diff) | |
| download | foop-41a31420cf091aeb4e986503387855d41e550106.tar.gz foop-41a31420cf091aeb4e986503387855d41e550106.tar.bz2 foop-41a31420cf091aeb4e986503387855d41e550106.zip | |
- add intro sound on every round
- add dieing sound
- add dieing animation
- add die on moving onto colorized block
Diffstat (limited to 'pacman-c++/actor.cpp')
| -rw-r--r-- | pacman-c++/actor.cpp | 49 |
1 files changed, 44 insertions, 5 deletions
diff --git a/pacman-c++/actor.cpp b/pacman-c++/actor.cpp index c8922f7..2dced34 100644 --- a/pacman-c++/actor.cpp +++ b/pacman-c++/actor.cpp | |||
| @@ -57,6 +57,29 @@ Actor::Actor(Color::Color color, bool local, QGraphicsItem *parent) | |||
| 57 | m_eating.append(setupEatingAnimation(Actor::Up)); | 57 | m_eating.append(setupEatingAnimation(Actor::Up)); |
| 58 | m_eating.append(setupEatingAnimation(Actor::Down)); | 58 | m_eating.append(setupEatingAnimation(Actor::Down)); |
| 59 | 59 | ||
| 60 | /* dieing animation */ | ||
| 61 | m_dieing = new QSequentialAnimationGroup(this); | ||
| 62 | for (int i = 0; i < 11; i++) | ||
| 63 | { | ||
| 64 | PixmapItem *img = new PixmapItem(m_pix, this); | ||
| 65 | m_images.append(img); | ||
| 66 | int x = i * Constants::sprite_offset + Constants::sprite_margin; | ||
| 67 | int y = 5 * Constants::sprite_offset + Constants::sprite_margin; | ||
| 68 | img->setSprite(x, y, Constants::field_size.width, Constants::field_size.height); | ||
| 69 | img->setZValue(zValue()); | ||
| 70 | img->setVisible(false); | ||
| 71 | |||
| 72 | QPropertyAnimation *fadein = new QPropertyAnimation(img, "visible", m_dieing); | ||
| 73 | fadein->setDuration(0); | ||
| 74 | fadein->setEndValue(true); | ||
| 75 | |||
| 76 | m_dieing->addPause(130); | ||
| 77 | |||
| 78 | QPropertyAnimation *fadeout = new QPropertyAnimation(img, "visible", m_dieing); | ||
| 79 | fadeout->setDuration(0); | ||
| 80 | fadeout->setEndValue(false); | ||
| 81 | } | ||
| 82 | |||
| 60 | /* setup waka sound */ | 83 | /* setup waka sound */ |
| 61 | if (local) | 84 | if (local) |
| 62 | m_wakaPlayer = new GaplessAudioPlayer(Sound::WakaWaka, 100, this); | 85 | m_wakaPlayer = new GaplessAudioPlayer(Sound::WakaWaka, 100, this); |
| @@ -112,11 +135,21 @@ bool Actor::isLocal() | |||
| 112 | return m_local; | 135 | return m_local; |
| 113 | } | 136 | } |
| 114 | 137 | ||
| 115 | void Actor::resetDirection() | 138 | void Actor::resetAnimation() |
| 116 | { | 139 | { |
| 140 | if (Constants::server) | ||
| 141 | return; | ||
| 142 | |||
| 143 | stopEating(); | ||
| 144 | m_moving->stop(); | ||
| 145 | m_dieing->stop(); | ||
| 117 | /* hide all pictures */ | 146 | /* hide all pictures */ |
| 118 | for (int i = 0; i < m_images.size(); ++i) | 147 | for (int i = 0; i < m_images.size(); ++i) |
| 119 | m_images.at(i)->setVisible(false); | 148 | m_images.at(i)->setVisible(false); |
| 149 | |||
| 150 | if (m_eating[m_direction] != NULL) | ||
| 151 | m_eating[m_direction]->stop(); | ||
| 152 | |||
| 120 | m_direction = Actor::None; | 153 | m_direction = Actor::None; |
| 121 | m_images[m_direction]->setVisible(true); | 154 | m_images[m_direction]->setVisible(true); |
| 122 | } | 155 | } |
| @@ -213,9 +246,14 @@ bool Actor::canEat(Actor *other, const QList<Color::Color> &order) | |||
| 213 | 246 | ||
| 214 | void Actor::die() | 247 | void Actor::die() |
| 215 | { | 248 | { |
| 216 | if (!m_local) | 249 | if (Constants::server) |
| 217 | return; | 250 | return; |
| 218 | AudioManager::self()->play(Sound::Die); | 251 | |
| 252 | resetAnimation(); | ||
| 253 | m_images[m_direction]->setVisible(false); | ||
| 254 | m_dieing->start(); | ||
| 255 | if (m_local) | ||
| 256 | AudioManager::self()->play(Sound::Die); | ||
| 219 | } | 257 | } |
| 220 | 258 | ||
| 221 | void Actor::eatingFruit() | 259 | void Actor::eatingFruit() |
| @@ -261,9 +299,10 @@ void Actor::addRoundPoints(unsigned int amount) | |||
| 261 | m_roundPoints += amount; | 299 | m_roundPoints += amount; |
| 262 | } | 300 | } |
| 263 | 301 | ||
| 264 | void Actor::finishRound() | 302 | void Actor::finishRound(bool died) |
| 265 | { | 303 | { |
| 266 | m_gamePoints += m_roundPoints; | 304 | if (!died) |
| 305 | m_gamePoints += m_roundPoints; | ||
| 267 | m_roundPoints = 0; | 306 | m_roundPoints = 0; |
| 268 | } | 307 | } |
| 269 | 308 | ||
