From 4232f8450d896068713d988cf5541835c3818682 Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 5 Apr 2011 01:29:33 +0200 Subject: - we love ogg, we hate mp3/wav - a lot of coding style/intent fix - add constant.h to pro files --- .gitignore | 1 + pacman-c++/actor.h | 1 - pacman-c++/animationmanager.cpp | 38 ++++++++--------- pacman-c++/animationmanager.h | 24 +++++------ pacman-c++/block.cpp | 11 +++-- pacman-c++/block.h | 8 ++-- pacman-c++/bonuspoint.cpp | 6 +-- pacman-c++/bonuspoint.h | 4 +- pacman-c++/client.h | 5 +-- pacman-c++/constants.h | 7 ++-- pacman-c++/main.cpp | 16 ++++---- pacman-c++/mainwidget.cpp | 81 ++++++++++++++++++++++++------------- pacman-c++/mainwidget.h | 5 +-- pacman-c++/pacman.pro | 4 +- pacman-c++/pacman_old.pro | 3 +- pacman-c++/sound/die.mp3 | Bin 27611 -> 0 bytes pacman-c++/sound/die.ogg | Bin 0 -> 12592 bytes pacman-c++/sound/eating_cherry.mp3 | Bin 10057 -> 0 bytes pacman-c++/sound/eating_cherry.ogg | Bin 0 -> 6062 bytes pacman-c++/sound/intermision.mp3 | Bin 86125 -> 0 bytes pacman-c++/sound/intermision.ogg | Bin 0 -> 29814 bytes pacman-c++/sound/intro.mp3 | Bin 70217 -> 0 bytes pacman-c++/sound/intro.ogg | Bin 0 -> 34469 bytes pacman-c++/sound/intro.wav | Bin 10990 -> 0 bytes pacman-c++/sound/siren.mp3 | Bin 29283 -> 0 bytes pacman-c++/sound/siren.ogg | Bin 0 -> 17170 bytes pacman-c++/sound/waka_waka.mp3 | Bin 12538 -> 0 bytes pacman-c++/sound/waka_waka.ogg | Bin 0 -> 9649 bytes 28 files changed, 115 insertions(+), 99 deletions(-) delete mode 100644 pacman-c++/sound/die.mp3 create mode 100644 pacman-c++/sound/die.ogg delete mode 100644 pacman-c++/sound/eating_cherry.mp3 create mode 100644 pacman-c++/sound/eating_cherry.ogg delete mode 100644 pacman-c++/sound/intermision.mp3 create mode 100644 pacman-c++/sound/intermision.ogg delete mode 100644 pacman-c++/sound/intro.mp3 create mode 100644 pacman-c++/sound/intro.ogg delete mode 100644 pacman-c++/sound/intro.wav delete mode 100644 pacman-c++/sound/siren.mp3 create mode 100644 pacman-c++/sound/siren.ogg delete mode 100644 pacman-c++/sound/waka_waka.mp3 create mode 100644 pacman-c++/sound/waka_waka.ogg diff --git a/.gitignore b/.gitignore index 4baf151..e123324 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ pacman-c++/*.o pacman-c++/*.moc *-build-debug *-build-release +*-build-desktop .*.swp diff --git a/pacman-c++/actor.h b/pacman-c++/actor.h index d2d7875..5bec353 100644 --- a/pacman-c++/actor.h +++ b/pacman-c++/actor.h @@ -2,7 +2,6 @@ #define ACTOR_H #include "pixmapitem.h" - #include "constants.h" class Actor diff --git a/pacman-c++/animationmanager.cpp b/pacman-c++/animationmanager.cpp index 69bec53..f4ddef7 100644 --- a/pacman-c++/animationmanager.cpp +++ b/pacman-c++/animationmanager.cpp @@ -11,46 +11,46 @@ AnimationManager::AnimationManager() AnimationManager *AnimationManager::self() { - if (!instance) - instance = new AnimationManager; - return instance; + if (!instance) + instance = new AnimationManager; + return instance; } void AnimationManager::registerAnimation(QAbstractAnimation *anim) { - QObject::connect(anim, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterAnimation_helper(QObject*))); - animations.append(anim); + QObject::connect(anim, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterAnimation_helper(QObject*))); + animations.append(anim); } void AnimationManager::unregisterAnimation_helper(QObject *obj) { - unregisterAnimation(static_cast(obj)); + unregisterAnimation(static_cast(obj)); } void AnimationManager::unregisterAnimation(QAbstractAnimation *anim) { - QObject::disconnect(anim, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterAnimation_helper(QObject*))); - animations.removeAll(anim); + QObject::disconnect(anim, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterAnimation_helper(QObject*))); + animations.removeAll(anim); } void AnimationManager::unregisterAllAnimations() { - animations.clear(); + animations.clear(); } void AnimationManager::pauseAll() { - foreach (QAbstractAnimation* animation, animations) - { - if (animation->state() == QAbstractAnimation::Running) - animation->pause(); - } + foreach (QAbstractAnimation* animation, animations) + { + if (animation->state() == QAbstractAnimation::Running) + animation->pause(); + } } void AnimationManager::resumeAll() { - foreach (QAbstractAnimation* animation, animations) - { - if (animation->state() == QAbstractAnimation::Paused) - animation->resume(); - } + foreach (QAbstractAnimation* animation, animations) + { + if (animation->state() == QAbstractAnimation::Paused) + animation->resume(); + } } diff --git a/pacman-c++/animationmanager.h b/pacman-c++/animationmanager.h index eb5b7d0..408395b 100644 --- a/pacman-c++/animationmanager.h +++ b/pacman-c++/animationmanager.h @@ -8,26 +8,26 @@ class QAbstractAnimation; QT_END_NAMESPACE class AnimationManager - : public QObject + : public QObject { -Q_OBJECT + Q_OBJECT public: - AnimationManager(); - void registerAnimation(QAbstractAnimation *anim); - void unregisterAnimation(QAbstractAnimation *anim); - void unregisterAllAnimations(); - static AnimationManager *self(); + AnimationManager(); + void registerAnimation(QAbstractAnimation *anim); + void unregisterAnimation(QAbstractAnimation *anim); + void unregisterAllAnimations(); + static AnimationManager *self(); public slots: - void pauseAll(); - void resumeAll(); + void pauseAll(); + void resumeAll(); private slots: - void unregisterAnimation_helper(QObject *obj); + void unregisterAnimation_helper(QObject *obj); private: - static AnimationManager *instance; - QList animations; + static AnimationManager *instance; + QList animations; }; #endif // ANIMATIONMANAGER_H diff --git a/pacman-c++/block.cpp b/pacman-c++/block.cpp index 9d57578..6383b3a 100644 --- a/pacman-c++/block.cpp +++ b/pacman-c++/block.cpp @@ -1,18 +1,17 @@ #include "block.h" - -#include - #include "constants.h" +#include std::map Block::m_pixmaps; Block::Block(Color color, QGraphicsItem *parent) : PixmapItem(parent) { - if (m_pixmaps.find(color) == m_pixmaps.end()) { + if (m_pixmaps.find(color) == m_pixmaps.end()) + { QString pixmapName = ":/" + QString("block%1").arg(color); - m_pixmaps[color] = QPixmap( pixmapName ); + m_pixmaps[color] = QPixmap(pixmapName); } - setPixmap( m_pixmaps.find(color)->second ); + setPixmap(m_pixmaps.find(color)->second); qDebug() << "loading block w color: " << color; } diff --git a/pacman-c++/block.h b/pacman-c++/block.h index 25f4f08..793d4a8 100644 --- a/pacman-c++/block.h +++ b/pacman-c++/block.h @@ -3,21 +3,19 @@ #include "pixmapitem.h" - -#include - #include "constants.h" +#include class Block - : public PixmapItem { + : public PixmapItem +{ public: Block(Color color, QGraphicsItem *parent=0); private: // map for saving QPixmaps for reuse static std::map m_pixmaps; - }; #endif // BLOCK_H diff --git a/pacman-c++/bonuspoint.cpp b/pacman-c++/bonuspoint.cpp index efff263..e2fdba0 100644 --- a/pacman-c++/bonuspoint.cpp +++ b/pacman-c++/bonuspoint.cpp @@ -1,14 +1,14 @@ #include "bonuspoint.h" -namespace { +namespace +{ QPixmap *pixmap = 0; } BonusPoint::BonusPoint(QGraphicsItem *parent) : PixmapItem(parent) { - if (pixmap == 0) { + if (pixmap == 0) pixmap = new QPixmap(":/cherry"); - } setPixmap(*pixmap); } diff --git a/pacman-c++/bonuspoint.h b/pacman-c++/bonuspoint.h index ebd1615..b14f582 100644 --- a/pacman-c++/bonuspoint.h +++ b/pacman-c++/bonuspoint.h @@ -8,8 +8,6 @@ class BonusPoint { public: BonusPoint(QGraphicsItem *parent=0); -private: - }; -#endif // BONUSPOINT_H \ No newline at end of file +#endif // BONUSPOINT_H diff --git a/pacman-c++/client.h b/pacman-c++/client.h index 2816ec2..272d110 100644 --- a/pacman-c++/client.h +++ b/pacman-c++/client.h @@ -1,9 +1,8 @@ #ifndef CLIENT_H #define CLIENT_H -#include - #include "mainwidget.h" +#include class Client : public QMainWindow { @@ -15,4 +14,4 @@ private: MainWidget *mainWidget; }; -#endif // CLIENT_H \ No newline at end of file +#endif // CLIENT_H diff --git a/pacman-c++/constants.h b/pacman-c++/constants.h index 088fcb8..d9362d8 100644 --- a/pacman-c++/constants.h +++ b/pacman-c++/constants.h @@ -4,7 +4,8 @@ const unsigned int map_size[2] = { 20, 20 }; const unsigned int field_size[2] = { 16, 16 }; -enum Color { +enum Color +{ noColor = 0, red = (1 << 0), blue = (1 << 1), @@ -12,8 +13,8 @@ enum Color { }; // constants for data transmission to client -namespace transmission { - +namespace transmission +{ typedef unsigned int field_t; typedef unsigned int mask_t; diff --git a/pacman-c++/main.cpp b/pacman-c++/main.cpp index a34ff97..8c9232a 100644 --- a/pacman-c++/main.cpp +++ b/pacman-c++/main.cpp @@ -4,6 +4,8 @@ #include #include #include +#include +#include int main(int argc, char **argv) { @@ -13,22 +15,18 @@ int main(int argc, char **argv) QGraphicsScene scene(0, 0, 500, 500); scene.setBackgroundBrush(Qt::black); - Actor *actor1 = new Actor(Actor::Player1); + Actor *actor1 = new Actor(red); scene.addItem(actor1); actor1->setPos(100, 100); - Actor *actor2 = new Actor(Actor::Player2); + Actor *actor2 = new Actor(blue); scene.addItem(actor2); actor2->setPos(120, 100); - Actor *actor3 = new Actor(Actor::Player3); + Actor *actor3 = new Actor(green); scene.addItem(actor3); actor3->setPos(140, 100); - Actor *actor4 = new Actor(Actor::Player4); - scene.addItem(actor4); - actor4->setPos(160, 100); - /* Block *block1 = new Block(Actor::Player1); scene.addItem(block1); @@ -36,7 +34,7 @@ int main(int argc, char **argv) */ for (unsigned int i=0; i<20; ++i) { - Block *b = new Block(Actor::Player1); + Block *b = new Block(red); scene.addItem(b); b->setPos( 100 + i*16, 200); } @@ -53,7 +51,7 @@ int main(int argc, char **argv) mainWin.show(); Phonon::MediaObject *music = Phonon::createPlayer(Phonon::MusicCategory, - Phonon::MediaSource("/home/totycro/stud/foop/repo/pacman-c++/sound/intro.wav")); + Phonon::MediaSource("/home/manuel/uni/foop/pacman-c++/sound/eating_cherry.ogg")); music->play(); qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); diff --git a/pacman-c++/mainwidget.cpp b/pacman-c++/mainwidget.cpp index cc85416..90d31b2 100644 --- a/pacman-c++/mainwidget.cpp +++ b/pacman-c++/mainwidget.cpp @@ -5,8 +5,8 @@ #include "bonuspoint.h" #include "constants.h" -MainWidget::MainWidget() { - +MainWidget::MainWidget() +{ QVBoxLayout *layout = new QVBoxLayout(this); QLabel *lbl = new QLabel("da kommt da spielstand hin", this); @@ -29,14 +29,17 @@ MainWidget::MainWidget() { } // temporary -transmission::map_t createDummyMap() { +transmission::map_t createDummyMap() +{ transmission::map_t map; map = new transmission::field_t*[map_size[0]]; - for (unsigned int i=0; iaddItem(actor); - actor->setPos( mapPositionToCoord(x, y) ); + actor->setPos(mapPositionToCoord(x, y)); } + Actor::Movement direction; - switch (cur & transmission::direction_mask) { - case transmission::direction_left: direction = Actor::Left; break; - case transmission::direction_right: direction = Actor::Right; break; - case transmission::direction_up: direction = Actor::Up; break; - case transmission::direction_down: direction = Actor::Down; break; - default: Q_ASSERT(false); + switch (cur & transmission::direction_mask) + { + case 0: + break; + case transmission::direction_left: + direction = Actor::Left; + break; + case transmission::direction_right: + direction = Actor::Right; + break; + case transmission::direction_up: + direction = Actor::Up; + break; + case transmission::direction_down: + direction = Actor::Down; + break; + default: + Q_ASSERT(false); } //actor->move(direction, mapPositionToCoord(x, y); - } else { Q_ASSERT(false); } - - if(item != 0) { + } + else + Q_ASSERT(false); + + if(item != 0) + { m_scene->addItem(item); - item->setPos( mapPositionToCoord(x, y) ); + item->setPos(mapPositionToCoord(x, y)); } } } diff --git a/pacman-c++/mainwidget.h b/pacman-c++/mainwidget.h index 184c542..f98cc42 100644 --- a/pacman-c++/mainwidget.h +++ b/pacman-c++/mainwidget.h @@ -1,11 +1,10 @@ #ifndef MAINWIDGET_H #define MAINWIDGET_H +#include "constants.h" #include #include -#include "constants.h" - class Actor; class MainWidget @@ -28,4 +27,4 @@ private: ActorMap m_actors; }; -#endif // MAINWIDGET_H \ No newline at end of file +#endif // MAINWIDGET_H diff --git a/pacman-c++/pacman.pro b/pacman-c++/pacman.pro index 6c39033..6282c5d 100644 --- a/pacman-c++/pacman.pro +++ b/pacman-c++/pacman.pro @@ -12,11 +12,11 @@ HEADERS += pixmapitem.h \ block.h \ client.h \ bonuspoint.h \ - mainwidget.h + mainwidget.h \ + constants.h RESOURCES += pacman.qrc OBJECTS_DIR = .obj MOC_DIR = .moc CONFIG += debug - diff --git a/pacman-c++/pacman_old.pro b/pacman-c++/pacman_old.pro index 501e924..c44e2c6 100644 --- a/pacman-c++/pacman_old.pro +++ b/pacman-c++/pacman_old.pro @@ -7,7 +7,8 @@ SOURCES += pixmapitem.cpp \ HEADERS += pixmapitem.h \ actor.h \ animationmanager.h \ - block.h + block.h \ + constants.h RESOURCES += pacman.qrc OBJECTS_DIR = .obj diff --git a/pacman-c++/sound/die.mp3 b/pacman-c++/sound/die.mp3 deleted file mode 100644 index 14c76bc..0000000 Binary files a/pacman-c++/sound/die.mp3 and /dev/null differ diff --git a/pacman-c++/sound/die.ogg b/pacman-c++/sound/die.ogg new file mode 100644 index 0000000..a698564 Binary files /dev/null and b/pacman-c++/sound/die.ogg differ diff --git a/pacman-c++/sound/eating_cherry.mp3 b/pacman-c++/sound/eating_cherry.mp3 deleted file mode 100644 index d63cb9e..0000000 Binary files a/pacman-c++/sound/eating_cherry.mp3 and /dev/null differ diff --git a/pacman-c++/sound/eating_cherry.ogg b/pacman-c++/sound/eating_cherry.ogg new file mode 100644 index 0000000..daa488e Binary files /dev/null and b/pacman-c++/sound/eating_cherry.ogg differ diff --git a/pacman-c++/sound/intermision.mp3 b/pacman-c++/sound/intermision.mp3 deleted file mode 100644 index 2e89a78..0000000 Binary files a/pacman-c++/sound/intermision.mp3 and /dev/null differ diff --git a/pacman-c++/sound/intermision.ogg b/pacman-c++/sound/intermision.ogg new file mode 100644 index 0000000..0af3567 Binary files /dev/null and b/pacman-c++/sound/intermision.ogg differ diff --git a/pacman-c++/sound/intro.mp3 b/pacman-c++/sound/intro.mp3 deleted file mode 100644 index 7aac980..0000000 Binary files a/pacman-c++/sound/intro.mp3 and /dev/null differ diff --git a/pacman-c++/sound/intro.ogg b/pacman-c++/sound/intro.ogg new file mode 100644 index 0000000..fa8b3e1 Binary files /dev/null and b/pacman-c++/sound/intro.ogg differ diff --git a/pacman-c++/sound/intro.wav b/pacman-c++/sound/intro.wav deleted file mode 100644 index 1fc4231..0000000 Binary files a/pacman-c++/sound/intro.wav and /dev/null differ diff --git a/pacman-c++/sound/siren.mp3 b/pacman-c++/sound/siren.mp3 deleted file mode 100644 index cbe9c4a..0000000 Binary files a/pacman-c++/sound/siren.mp3 and /dev/null differ diff --git a/pacman-c++/sound/siren.ogg b/pacman-c++/sound/siren.ogg new file mode 100644 index 0000000..70a56b2 Binary files /dev/null and b/pacman-c++/sound/siren.ogg differ diff --git a/pacman-c++/sound/waka_waka.mp3 b/pacman-c++/sound/waka_waka.mp3 deleted file mode 100644 index 69791d3..0000000 Binary files a/pacman-c++/sound/waka_waka.mp3 and /dev/null differ diff --git a/pacman-c++/sound/waka_waka.ogg b/pacman-c++/sound/waka_waka.ogg new file mode 100644 index 0000000..a2b879f Binary files /dev/null and b/pacman-c++/sound/waka_waka.ogg differ -- cgit v1.2.3