diff options
Diffstat (limited to 'pacman-c++')
| -rw-r--r-- | pacman-c++/block.cpp | 7 | ||||
| -rw-r--r-- | pacman-c++/block.h | 14 | ||||
| -rw-r--r-- | pacman-c++/main.cpp | 5 | ||||
| -rw-r--r-- | pacman-c++/pacman.pro | 6 | ||||
| -rw-r--r-- | pacman-c++/pacman.qrc | 1 | ||||
| -rw-r--r-- | pacman-c++/pics/block1.png | bin | 0 -> 179 bytes |
6 files changed, 31 insertions, 2 deletions
diff --git a/pacman-c++/block.cpp b/pacman-c++/block.cpp new file mode 100644 index 0000000..69f2cd3 --- /dev/null +++ b/pacman-c++/block.cpp | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | #include "block.h" | ||
| 2 | |||
| 3 | #include <Qt> | ||
| 4 | |||
| 5 | Block::Block(Actor::Type type) { | ||
| 6 | setPixmap(QPixmap(":/" + QString("block%1").arg(type))); | ||
| 7 | } | ||
diff --git a/pacman-c++/block.h b/pacman-c++/block.h new file mode 100644 index 0000000..17f5903 --- /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 | |||
| 7 | class Block | ||
| 8 | : public PixmapItem { | ||
| 9 | public: | ||
| 10 | Block(Actor::Type type); | ||
| 11 | |||
| 12 | }; | ||
| 13 | |||
| 14 | #endif // BLOCK_H \ No newline at end of file | ||
diff --git a/pacman-c++/main.cpp b/pacman-c++/main.cpp index aa9a229..2d3ff67 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 "pixmapitem.h" | 3 | #include "pixmapitem.h" |
| 3 | #include <QtCore> | 4 | #include <QtCore> |
| 4 | #include <QtGui> | 5 | #include <QtGui> |
| @@ -14,6 +15,10 @@ int main(int argc, char **argv) | |||
| 14 | scene.addItem(actor1); | 15 | scene.addItem(actor1); |
| 15 | actor1->setPos(100, 100); | 16 | actor1->setPos(100, 100); |
| 16 | 17 | ||
| 18 | Block *block1 = new Block(Actor::Player1); | ||
| 19 | scene.addItem(block1); | ||
| 20 | block1->setPos(200, 200); | ||
| 21 | |||
| 17 | QGraphicsView *window = new QGraphicsView(&scene); | 22 | QGraphicsView *window = new QGraphicsView(&scene); |
| 18 | window->setFrameStyle(0); | 23 | window->setFrameStyle(0); |
| 19 | window->setAlignment(Qt::AlignLeft | Qt::AlignTop); | 24 | 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 @@ | |||
| 1 | SOURCES += main.cpp \ | 1 | SOURCES += main.cpp \ |
| 2 | pixmapitem.cpp \ | 2 | pixmapitem.cpp \ |
| 3 | actor.cpp \ | 3 | actor.cpp \ |
| 4 | animationmanager.cpp | 4 | animationmanager.cpp \ |
| 5 | block.cpp | ||
| 5 | HEADERS += pixmapitem.h \ | 6 | HEADERS += pixmapitem.h \ |
| 6 | actor.h \ | 7 | actor.h \ |
| 7 | animationmanager.h | 8 | animationmanager.h \ |
| 9 | block.h | ||
| 8 | RESOURCES += pacman.qrc | 10 | RESOURCES += pacman.qrc |
| 9 | 11 | ||
| 10 | 12 | ||
diff --git a/pacman-c++/pacman.qrc b/pacman-c++/pacman.qrc index a643886..15c7985 100644 --- a/pacman-c++/pacman.qrc +++ b/pacman-c++/pacman.qrc | |||
| @@ -2,5 +2,6 @@ | |||
| 2 | <qresource prefix="/"> | 2 | <qresource prefix="/"> |
| 3 | <file alias="google-pacman-sprite">pics/pacman10-hp-sprite-2.png</file> | 3 | <file alias="google-pacman-sprite">pics/pacman10-hp-sprite-2.png</file> |
| 4 | <file alias="actor1">pics/actor1.png</file> | 4 | <file alias="actor1">pics/actor1.png</file> |
| 5 | <file alias="block1">pics/block1.png</file> | ||
| 5 | </qresource> | 6 | </qresource> |
| 6 | </RCC> | 7 | </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 | |||
