From 471177aad38350840eed6452b1ad8723b61c330d Mon Sep 17 00:00:00 2001 From: manuel Date: Mon, 4 Apr 2011 14:40:13 +0200 Subject: add more pacmans --- pacman-c++/actor.cpp | 8 +++++--- pacman-c++/actor.h | 6 +++--- pacman-c++/main.cpp | 9 ++++++++- pacman-c++/pacman.qrc | 4 +++- pacman-c++/pics/actor1.png | Bin 485 -> 704 bytes pacman-c++/pics/actor2.png | Bin 0 -> 711 bytes pacman-c++/pics/actor3.png | Bin 0 -> 703 bytes pacman-c++/pics/actor4.png | Bin 0 -> 706 bytes pacman-c++/pixmapitem.cpp | 1 - 9 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 pacman-c++/pics/actor2.png create mode 100644 pacman-c++/pics/actor3.png create mode 100644 pacman-c++/pics/actor4.png diff --git a/pacman-c++/actor.cpp b/pacman-c++/actor.cpp index e98545b..4704ed1 100644 --- a/pacman-c++/actor.cpp +++ b/pacman-c++/actor.cpp @@ -18,9 +18,10 @@ static QVariant myBooleanInterpolator(const bool &start, const bool &end, qreal Actor::Actor(Type type) : m_type(type), m_direction(Actor::None) { - m_pix = ":/" + QString("actor%1").arg(type); - setPixmap(m_pix); + m_pix = ":/" + QString("actor%1").arg(m_type); setSprite(82, 82, SPRITE_PLAYER_WIDTH, SPRITE_PLAYER_HEIGHT); + // higher player "over" lower player + setZValue(m_type * 10); m_direction = Actor::Left; @@ -36,6 +37,7 @@ Actor::Actor(Type type) int x = i * 20 + SPRITE_MARGIN; int y = m_direction * 20 + SPRITE_MARGIN; img->setSprite(x, y, SPRITE_PLAYER_WIDTH, SPRITE_PLAYER_HEIGHT); + img->setZValue(zValue()); img->setVisible(false); img->setPos(QPointF(200, 0)); @@ -50,7 +52,7 @@ Actor::Actor(Type type) fadeout->setEndValue(false); QPropertyAnimation *move = new QPropertyAnimation(img, "pos", moving); - move->setDuration(10000); + move->setDuration(5000); move->setEndValue(QPointF(0, 0)); } diff --git a/pacman-c++/actor.h b/pacman-c++/actor.h index 43314a9..16a0c72 100644 --- a/pacman-c++/actor.h +++ b/pacman-c++/actor.h @@ -16,9 +16,9 @@ public: }; enum Type { - Player1 = 1, - Player2, - Player3, + Player1 = 1, // red + Player2, // blue + Player3, // yellow }; Actor(Type type); diff --git a/pacman-c++/main.cpp b/pacman-c++/main.cpp index aa9a229..14a3ee9 100644 --- a/pacman-c++/main.cpp +++ b/pacman-c++/main.cpp @@ -1,5 +1,4 @@ #include "actor.h" -#include "pixmapitem.h" #include #include @@ -14,6 +13,14 @@ int main(int argc, char **argv) scene.addItem(actor1); actor1->setPos(100, 100); + Actor *actor2 = new Actor(Actor::Player2); + scene.addItem(actor2); + actor2->setPos(120, 100); + + Actor *actor3 = new Actor(Actor::Player3); + scene.addItem(actor3); + actor3->setPos(140, 100); + QGraphicsView *window = new QGraphicsView(&scene); window->setFrameStyle(0); window->setAlignment(Qt::AlignLeft | Qt::AlignTop); diff --git a/pacman-c++/pacman.qrc b/pacman-c++/pacman.qrc index a643886..196ee43 100644 --- a/pacman-c++/pacman.qrc +++ b/pacman-c++/pacman.qrc @@ -1,6 +1,8 @@ - pics/pacman10-hp-sprite-2.png pics/actor1.png + pics/actor2.png + pics/actor3.png + pics/actor4.png diff --git a/pacman-c++/pics/actor1.png b/pacman-c++/pics/actor1.png index 2b4a32a..b1304cd 100644 Binary files a/pacman-c++/pics/actor1.png and b/pacman-c++/pics/actor1.png differ diff --git a/pacman-c++/pics/actor2.png b/pacman-c++/pics/actor2.png new file mode 100644 index 0000000..cac3786 Binary files /dev/null and b/pacman-c++/pics/actor2.png differ diff --git a/pacman-c++/pics/actor3.png b/pacman-c++/pics/actor3.png new file mode 100644 index 0000000..99e025c Binary files /dev/null and b/pacman-c++/pics/actor3.png differ diff --git a/pacman-c++/pics/actor4.png b/pacman-c++/pics/actor4.png new file mode 100644 index 0000000..9947f9b Binary files /dev/null and b/pacman-c++/pics/actor4.png differ diff --git a/pacman-c++/pixmapitem.cpp b/pacman-c++/pixmapitem.cpp index b0a81d0..84517c2 100644 --- a/pacman-c++/pixmapitem.cpp +++ b/pacman-c++/pixmapitem.cpp @@ -1,6 +1,5 @@ #include "pixmapitem.h" #include -#include PixmapItem::PixmapItem(QGraphicsItem *parent) : QGraphicsObject(parent), m_x(0), m_y(0) -- cgit v1.2.3