summaryrefslogtreecommitdiffstats
path: root/pacman-c++
diff options
context:
space:
mode:
Diffstat (limited to 'pacman-c++')
-rw-r--r--pacman-c++/actor.cpp8
-rw-r--r--pacman-c++/actor.h7
-rw-r--r--pacman-c++/block.cpp3
-rw-r--r--pacman-c++/block.h2
-rw-r--r--pacman-c++/main.cpp13
-rw-r--r--pacman-c++/pacman.qrc4
-rw-r--r--pacman-c++/pics/actor1.pngbin485 -> 704 bytes
-rw-r--r--pacman-c++/pics/actor2.pngbin0 -> 711 bytes
-rw-r--r--pacman-c++/pics/actor3.pngbin0 -> 703 bytes
-rw-r--r--pacman-c++/pics/actor4.pngbin0 -> 706 bytes
-rw-r--r--pacman-c++/pixmapitem.cpp1
11 files changed, 27 insertions, 11 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
18Actor::Actor(Type type) 18Actor::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..f5844bb 100644
--- a/pacman-c++/actor.h
+++ b/pacman-c++/actor.h
@@ -16,9 +16,10 @@ 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, // green
22 Player4, // yellow
22 }; 23 };
23 24
24 Actor(Type type); 25 Actor(Type type);
diff --git a/pacman-c++/block.cpp b/pacman-c++/block.cpp
index 69f2cd3..11c2a32 100644
--- a/pacman-c++/block.cpp
+++ b/pacman-c++/block.cpp
@@ -2,6 +2,7 @@
2 2
3#include <Qt> 3#include <Qt>
4 4
5Block::Block(Actor::Type type) { 5Block::Block(Actor::Type type)
6{
6 setPixmap(QPixmap(":/" + QString("block%1").arg(type))); 7 setPixmap(QPixmap(":/" + QString("block%1").arg(type)));
7} 8}
diff --git a/pacman-c++/block.h b/pacman-c++/block.h
index 17f5903..25a331c 100644
--- a/pacman-c++/block.h
+++ b/pacman-c++/block.h
@@ -11,4 +11,4 @@ public:
11 11
12}; 12};
13 13
14#endif // BLOCK_H \ No newline at end of file 14#endif // BLOCK_H
diff --git a/pacman-c++/main.cpp b/pacman-c++/main.cpp
index 2d3ff67..6f6e5df 100644
--- a/pacman-c++/main.cpp
+++ b/pacman-c++/main.cpp
@@ -1,6 +1,5 @@
1#include "actor.h" 1#include "actor.h"
2#include "block.h" 2#include "block.h"
3#include "pixmapitem.h"
4#include <QtCore> 3#include <QtCore>
5#include <QtGui> 4#include <QtGui>
6 5
@@ -15,6 +14,18 @@ int main(int argc, char **argv)
15 scene.addItem(actor1); 14 scene.addItem(actor1);
16 actor1->setPos(100, 100); 15 actor1->setPos(100, 100);
17 16
17 Actor *actor2 = new Actor(Actor::Player2);
18 scene.addItem(actor2);
19 actor2->setPos(120, 100);
20
21 Actor *actor3 = new Actor(Actor::Player3);
22 scene.addItem(actor3);
23 actor3->setPos(140, 100);
24
25 Actor *actor4 = new Actor(Actor::Player4);
26 scene.addItem(actor4);
27 actor4->setPos(160, 100);
28
18 Block *block1 = new Block(Actor::Player1); 29 Block *block1 = new Block(Actor::Player1);
19 scene.addItem(block1); 30 scene.addItem(block1);
20 block1->setPos(200, 200); 31 block1->setPos(200, 200);
diff --git a/pacman-c++/pacman.qrc b/pacman-c++/pacman.qrc
index 15c7985..6a7fefb 100644
--- a/pacman-c++/pacman.qrc
+++ b/pacman-c++/pacman.qrc
@@ -1,7 +1,9 @@
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 <file alias="block1">pics/block1.png</file> 7 <file alias="block1">pics/block1.png</file>
6 </qresource> 8 </qresource>
7</RCC> 9</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
5PixmapItem::PixmapItem(QGraphicsItem *parent) 4PixmapItem::PixmapItem(QGraphicsItem *parent)
6 : QGraphicsObject(parent), m_x(0), m_y(0) 5 : QGraphicsObject(parent), m_x(0), m_y(0)