From f3f2cc63376019aaf9e8dd807ab674f92908123c Mon Sep 17 00:00:00 2001 From: manuel Date: Mon, 4 Apr 2011 18:52:02 +0200 Subject: adding sound --- pacman-c++/actor.cpp | 7 ++++--- pacman-c++/actor.h | 2 +- pacman-c++/main.cpp | 7 +++++++ pacman-c++/pacman.pro | 1 + pacman-c++/sound/die.mp3 | Bin 0 -> 27611 bytes pacman-c++/sound/eating_cherry.mp3 | Bin 0 -> 10057 bytes pacman-c++/sound/intermision.mp3 | Bin 0 -> 86125 bytes pacman-c++/sound/intro.mp3 | Bin 0 -> 70217 bytes pacman-c++/sound/intro.wav | Bin 0 -> 10990 bytes pacman-c++/sound/siren.mp3 | Bin 0 -> 29283 bytes pacman-c++/sound/waka_waka.mp3 | Bin 0 -> 12538 bytes 11 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 pacman-c++/sound/die.mp3 create mode 100644 pacman-c++/sound/eating_cherry.mp3 create mode 100644 pacman-c++/sound/intermision.mp3 create mode 100644 pacman-c++/sound/intro.mp3 create mode 100644 pacman-c++/sound/intro.wav create mode 100644 pacman-c++/sound/siren.mp3 create mode 100644 pacman-c++/sound/waka_waka.mp3 diff --git a/pacman-c++/actor.cpp b/pacman-c++/actor.cpp index 4704ed1..5f668fc 100644 --- a/pacman-c++/actor.cpp +++ b/pacman-c++/actor.cpp @@ -15,11 +15,12 @@ static QVariant myBooleanInterpolator(const bool &start, const bool &end, qreal return (progress == 1.0) ? end : start; } -Actor::Actor(Type type) - : m_type(type), m_direction(Actor::None) +Actor::Actor(Type type, QGraphicsItem *parent) + : PixmapItem(parent), m_type(type), m_direction(Actor::None) { m_pix = ":/" + QString("actor%1").arg(m_type); - setSprite(82, 82, SPRITE_PLAYER_WIDTH, SPRITE_PLAYER_HEIGHT); + // DON'T set any pixmap here. we've a pixmap in the animation + //setPixmap(m_pix); // higher player "over" lower player setZValue(m_type * 10); diff --git a/pacman-c++/actor.h b/pacman-c++/actor.h index f5844bb..3cee699 100644 --- a/pacman-c++/actor.h +++ b/pacman-c++/actor.h @@ -22,7 +22,7 @@ public: Player4, // yellow }; - Actor(Type type); + Actor(Type type, QGraphicsItem *parent = 0); private: QPixmap m_pix; diff --git a/pacman-c++/main.cpp b/pacman-c++/main.cpp index 6f6e5df..ed347fe 100644 --- a/pacman-c++/main.cpp +++ b/pacman-c++/main.cpp @@ -1,11 +1,14 @@ #include "actor.h" #include "block.h" + #include #include +#include int main(int argc, char **argv) { QApplication app(argc, argv); + app.setApplicationName("pacman"); QGraphicsScene scene(0, 0, 500, 500); scene.setBackgroundBrush(Qt::black); @@ -40,6 +43,10 @@ int main(int argc, char **argv) mainWin.setCentralWidget(window); mainWin.resize(500, 500); mainWin.show(); + + Phonon::MediaObject *music = Phonon::createPlayer(Phonon::MusicCategory, + Phonon::MediaSource("/home/manuel/uni/foop/pacman-c++/sound/intro.wav")); + music->play(); qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); diff --git a/pacman-c++/pacman.pro b/pacman-c++/pacman.pro index 99feed0..2bb8629 100644 --- a/pacman-c++/pacman.pro +++ b/pacman-c++/pacman.pro @@ -1,3 +1,4 @@ +QT += phonon SOURCES += main.cpp \ pixmapitem.cpp \ actor.cpp \ diff --git a/pacman-c++/sound/die.mp3 b/pacman-c++/sound/die.mp3 new file mode 100644 index 0000000..14c76bc Binary files /dev/null and b/pacman-c++/sound/die.mp3 differ diff --git a/pacman-c++/sound/eating_cherry.mp3 b/pacman-c++/sound/eating_cherry.mp3 new file mode 100644 index 0000000..d63cb9e Binary files /dev/null and b/pacman-c++/sound/eating_cherry.mp3 differ diff --git a/pacman-c++/sound/intermision.mp3 b/pacman-c++/sound/intermision.mp3 new file mode 100644 index 0000000..2e89a78 Binary files /dev/null and b/pacman-c++/sound/intermision.mp3 differ diff --git a/pacman-c++/sound/intro.mp3 b/pacman-c++/sound/intro.mp3 new file mode 100644 index 0000000..7aac980 Binary files /dev/null and b/pacman-c++/sound/intro.mp3 differ diff --git a/pacman-c++/sound/intro.wav b/pacman-c++/sound/intro.wav new file mode 100644 index 0000000..1fc4231 Binary files /dev/null and b/pacman-c++/sound/intro.wav differ diff --git a/pacman-c++/sound/siren.mp3 b/pacman-c++/sound/siren.mp3 new file mode 100644 index 0000000..cbe9c4a Binary files /dev/null and b/pacman-c++/sound/siren.mp3 differ diff --git a/pacman-c++/sound/waka_waka.mp3 b/pacman-c++/sound/waka_waka.mp3 new file mode 100644 index 0000000..69791d3 Binary files /dev/null and b/pacman-c++/sound/waka_waka.mp3 differ -- cgit v1.2.3