diff options
| author | manuel <manuel@mausz.at> | 2011-04-04 14:40:13 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2011-04-04 14:40:13 +0200 |
| commit | 471177aad38350840eed6452b1ad8723b61c330d (patch) | |
| tree | 02f568f52cfe3ecd4c48fe9a96086ac3f748cd59 | |
| parent | 03c82aa4ebb40b7c6ba5a304df6ff11b85afe80d (diff) | |
| download | foop-471177aad38350840eed6452b1ad8723b61c330d.tar.gz foop-471177aad38350840eed6452b1ad8723b61c330d.tar.bz2 foop-471177aad38350840eed6452b1ad8723b61c330d.zip | |
add more pacmans
| -rw-r--r-- | pacman-c++/actor.cpp | 8 | ||||
| -rw-r--r-- | pacman-c++/actor.h | 6 | ||||
| -rw-r--r-- | pacman-c++/main.cpp | 9 | ||||
| -rw-r--r-- | pacman-c++/pacman.qrc | 4 | ||||
| -rw-r--r-- | pacman-c++/pics/actor1.png | bin | 485 -> 704 bytes | |||
| -rw-r--r-- | pacman-c++/pics/actor2.png | bin | 0 -> 711 bytes | |||
| -rw-r--r-- | pacman-c++/pics/actor3.png | bin | 0 -> 703 bytes | |||
| -rw-r--r-- | pacman-c++/pics/actor4.png | bin | 0 -> 706 bytes | |||
| -rw-r--r-- | pacman-c++/pixmapitem.cpp | 1 |
9 files changed, 19 insertions, 9 deletions
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 | |||
| 18 | Actor::Actor(Type type) | 18 | Actor::Actor(Type type) |
| 19 | : m_type(type), m_direction(Actor::None) | 19 | : m_type(type), m_direction(Actor::None) |
| 20 | { | 20 | { |
| 21 | m_pix = ":/" + QString("actor%1").arg(type); | 21 | m_pix = ":/" + QString("actor%1").arg(m_type); |
| 22 | setPixmap(m_pix); | ||
| 23 | setSprite(82, 82, SPRITE_PLAYER_WIDTH, SPRITE_PLAYER_HEIGHT); | 22 | setSprite(82, 82, SPRITE_PLAYER_WIDTH, SPRITE_PLAYER_HEIGHT); |
| 23 | // higher player "over" lower player | ||
| 24 | setZValue(m_type * 10); | ||
| 24 | 25 | ||
| 25 | m_direction = Actor::Left; | 26 | m_direction = Actor::Left; |
| 26 | 27 | ||
| @@ -36,6 +37,7 @@ Actor::Actor(Type type) | |||
| 36 | int x = i * 20 + SPRITE_MARGIN; | 37 | int x = i * 20 + SPRITE_MARGIN; |
| 37 | int y = m_direction * 20 + SPRITE_MARGIN; | 38 | int y = m_direction * 20 + SPRITE_MARGIN; |
| 38 | img->setSprite(x, y, SPRITE_PLAYER_WIDTH, SPRITE_PLAYER_HEIGHT); | 39 | img->setSprite(x, y, SPRITE_PLAYER_WIDTH, SPRITE_PLAYER_HEIGHT); |
| 40 | img->setZValue(zValue()); | ||
| 39 | img->setVisible(false); | 41 | img->setVisible(false); |
| 40 | img->setPos(QPointF(200, 0)); | 42 | img->setPos(QPointF(200, 0)); |
| 41 | 43 | ||
| @@ -50,7 +52,7 @@ Actor::Actor(Type type) | |||
| 50 | fadeout->setEndValue(false); | 52 | fadeout->setEndValue(false); |
| 51 | 53 | ||
| 52 | QPropertyAnimation *move = new QPropertyAnimation(img, "pos", moving); | 54 | QPropertyAnimation *move = new QPropertyAnimation(img, "pos", moving); |
| 53 | move->setDuration(10000); | 55 | move->setDuration(5000); |
| 54 | move->setEndValue(QPointF(0, 0)); | 56 | move->setEndValue(QPointF(0, 0)); |
| 55 | } | 57 | } |
| 56 | 58 | ||
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: | |||
| 16 | }; | 16 | }; |
| 17 | 17 | ||
| 18 | enum Type { | 18 | enum Type { |
| 19 | Player1 = 1, | 19 | Player1 = 1, // red |
| 20 | Player2, | 20 | Player2, // blue |
| 21 | Player3, | 21 | Player3, // yellow |
| 22 | }; | 22 | }; |
| 23 | 23 | ||
| 24 | Actor(Type type); | 24 | 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 @@ | |||
| 1 | #include "actor.h" | 1 | #include "actor.h" |
| 2 | #include "pixmapitem.h" | ||
| 3 | #include <QtCore> | 2 | #include <QtCore> |
| 4 | #include <QtGui> | 3 | #include <QtGui> |
| 5 | 4 | ||
| @@ -14,6 +13,14 @@ int main(int argc, char **argv) | |||
| 14 | scene.addItem(actor1); | 13 | scene.addItem(actor1); |
| 15 | actor1->setPos(100, 100); | 14 | actor1->setPos(100, 100); |
| 16 | 15 | ||
| 16 | Actor *actor2 = new Actor(Actor::Player2); | ||
| 17 | scene.addItem(actor2); | ||
| 18 | actor2->setPos(120, 100); | ||
| 19 | |||
| 20 | Actor *actor3 = new Actor(Actor::Player3); | ||
| 21 | scene.addItem(actor3); | ||
| 22 | actor3->setPos(140, 100); | ||
| 23 | |||
| 17 | QGraphicsView *window = new QGraphicsView(&scene); | 24 | QGraphicsView *window = new QGraphicsView(&scene); |
| 18 | window->setFrameStyle(0); | 25 | window->setFrameStyle(0); |
| 19 | window->setAlignment(Qt::AlignLeft | Qt::AlignTop); | 26 | 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 @@ | |||
| 1 | <RCC> | 1 | <RCC> |
| 2 | <qresource prefix="/"> | 2 | <qresource prefix="/"> |
| 3 | <file alias="google-pacman-sprite">pics/pacman10-hp-sprite-2.png</file> | ||
| 4 | <file alias="actor1">pics/actor1.png</file> | 3 | <file alias="actor1">pics/actor1.png</file> |
| 4 | <file alias="actor2">pics/actor2.png</file> | ||
| 5 | <file alias="actor3">pics/actor3.png</file> | ||
| 6 | <file alias="actor4">pics/actor4.png</file> | ||
| 5 | </qresource> | 7 | </qresource> |
| 6 | </RCC> | 8 | </RCC> |
diff --git a/pacman-c++/pics/actor1.png b/pacman-c++/pics/actor1.png index 2b4a32a..b1304cd 100644 --- a/pacman-c++/pics/actor1.png +++ b/pacman-c++/pics/actor1.png | |||
| Binary files differ | |||
diff --git a/pacman-c++/pics/actor2.png b/pacman-c++/pics/actor2.png new file mode 100644 index 0000000..cac3786 --- /dev/null +++ b/pacman-c++/pics/actor2.png | |||
| Binary files differ | |||
diff --git a/pacman-c++/pics/actor3.png b/pacman-c++/pics/actor3.png new file mode 100644 index 0000000..99e025c --- /dev/null +++ b/pacman-c++/pics/actor3.png | |||
| Binary files differ | |||
diff --git a/pacman-c++/pics/actor4.png b/pacman-c++/pics/actor4.png new file mode 100644 index 0000000..9947f9b --- /dev/null +++ b/pacman-c++/pics/actor4.png | |||
| Binary files 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 @@ | |||
| 1 | #include "pixmapitem.h" | 1 | #include "pixmapitem.h" |
| 2 | #include <QPainter> | 2 | #include <QPainter> |
| 3 | #include <QDebug> | ||
| 4 | 3 | ||
| 5 | PixmapItem::PixmapItem(QGraphicsItem *parent) | 4 | PixmapItem::PixmapItem(QGraphicsItem *parent) |
| 6 | : QGraphicsObject(parent), m_x(0), m_y(0) | 5 | : QGraphicsObject(parent), m_x(0), m_y(0) |
