summaryrefslogtreecommitdiffstats
path: root/pacman-c++
diff options
context:
space:
mode:
Diffstat (limited to 'pacman-c++')
-rw-r--r--pacman-c++/actor.h3
-rw-r--r--pacman-c++/block.cpp8
-rw-r--r--pacman-c++/block.h14
-rw-r--r--pacman-c++/main.cpp9
-rw-r--r--pacman-c++/pacman.pro6
-rw-r--r--pacman-c++/pacman.qrc1
-rw-r--r--pacman-c++/pics/block1.pngbin0 -> 179 bytes
7 files changed, 38 insertions, 3 deletions
diff --git a/pacman-c++/actor.h b/pacman-c++/actor.h
index 16a0c72..f5844bb 100644
--- a/pacman-c++/actor.h
+++ b/pacman-c++/actor.h
@@ -18,7 +18,8 @@ public:
18 enum Type { 18 enum Type {
19 Player1 = 1, // red 19 Player1 = 1, // red
20 Player2, // blue 20 Player2, // blue
21 Player3, // yellow 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
new file mode 100644
index 0000000..11c2a32
--- /dev/null
+++ b/pacman-c++/block.cpp
@@ -0,0 +1,8 @@
1#include "block.h"
2
3#include <Qt>
4
5Block::Block(Actor::Type type)
6{
7 setPixmap(QPixmap(":/" + QString("block%1").arg(type)));
8}
diff --git a/pacman-c++/block.h b/pacman-c++/block.h
new file mode 100644
index 0000000..25a331c
--- /dev/null
+++ b/pacman-c++/block.h
@@ -0,0 +1,14 @@
1#ifndef BLOCK_H
2#define BLOCK_H
3
4#include "pixmapitem.h"
5#include "actor.h"
6
7class Block
8 : public PixmapItem {
9public:
10 Block(Actor::Type type);
11
12};
13
14#endif // BLOCK_H
diff --git a/pacman-c++/main.cpp b/pacman-c++/main.cpp
index 14a3ee9..6f6e5df 100644
--- a/pacman-c++/main.cpp
+++ b/pacman-c++/main.cpp
@@ -1,4 +1,5 @@
1#include "actor.h" 1#include "actor.h"
2#include "block.h"
2#include <QtCore> 3#include <QtCore>
3#include <QtGui> 4#include <QtGui>
4 5
@@ -21,6 +22,14 @@ int main(int argc, char **argv)
21 scene.addItem(actor3); 22 scene.addItem(actor3);
22 actor3->setPos(140, 100); 23 actor3->setPos(140, 100);
23 24
25 Actor *actor4 = new Actor(Actor::Player4);
26 scene.addItem(actor4);
27 actor4->setPos(160, 100);
28
29 Block *block1 = new Block(Actor::Player1);
30 scene.addItem(block1);
31 block1->setPos(200, 200);
32
24 QGraphicsView *window = new QGraphicsView(&scene); 33 QGraphicsView *window = new QGraphicsView(&scene);
25 window->setFrameStyle(0); 34 window->setFrameStyle(0);
26 window->setAlignment(Qt::AlignLeft | Qt::AlignTop); 35 window->setAlignment(Qt::AlignLeft | Qt::AlignTop);
diff --git a/pacman-c++/pacman.pro b/pacman-c++/pacman.pro
index 3ce84da..99feed0 100644
--- a/pacman-c++/pacman.pro
+++ b/pacman-c++/pacman.pro
@@ -1,10 +1,12 @@
1SOURCES += main.cpp \ 1SOURCES += main.cpp \
2 pixmapitem.cpp \ 2 pixmapitem.cpp \
3 actor.cpp \ 3 actor.cpp \
4 animationmanager.cpp 4 animationmanager.cpp \
5 block.cpp
5HEADERS += pixmapitem.h \ 6HEADERS += pixmapitem.h \
6 actor.h \ 7 actor.h \
7 animationmanager.h 8 animationmanager.h \
9 block.h
8RESOURCES += pacman.qrc 10RESOURCES += pacman.qrc
9 11
10 12
diff --git a/pacman-c++/pacman.qrc b/pacman-c++/pacman.qrc
index 196ee43..6a7fefb 100644
--- a/pacman-c++/pacman.qrc
+++ b/pacman-c++/pacman.qrc
@@ -4,5 +4,6 @@
4 <file alias="actor2">pics/actor2.png</file> 4 <file alias="actor2">pics/actor2.png</file>
5 <file alias="actor3">pics/actor3.png</file> 5 <file alias="actor3">pics/actor3.png</file>
6 <file alias="actor4">pics/actor4.png</file> 6 <file alias="actor4">pics/actor4.png</file>
7 <file alias="block1">pics/block1.png</file>
7 </qresource> 8 </qresource>
8</RCC> 9</RCC>
diff --git a/pacman-c++/pics/block1.png b/pacman-c++/pics/block1.png
new file mode 100644
index 0000000..4188bcf
--- /dev/null
+++ b/pacman-c++/pics/block1.png
Binary files differ