summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pacman-c++/actor.cpp3
-rw-r--r--pacman-c++/bonuspoint.cpp1
-rw-r--r--pacman-c++/constants.h14
-rw-r--r--pacman-c++/mainwidget.cpp17
-rw-r--r--pacman-c++/pacman.pro6
-rw-r--r--pacman-c++/pics/points.pngbin175 -> 181 bytes
-rw-r--r--pacman-c++/point.cpp17
-rw-r--r--pacman-c++/point.h14
8 files changed, 59 insertions, 13 deletions
diff --git a/pacman-c++/actor.cpp b/pacman-c++/actor.cpp
index 1796091..b6de49c 100644
--- a/pacman-c++/actor.cpp
+++ b/pacman-c++/actor.cpp
@@ -76,6 +76,7 @@ QSequentialAnimationGroup *Actor::setupEatingAnimation(Actor::Movement direction
76 76
77 QPropertyAnimation *move = new QPropertyAnimation(img, "pos", m_moving); 77 QPropertyAnimation *move = new QPropertyAnimation(img, "pos", m_moving);
78 move->setDuration(Constants::tick); 78 move->setDuration(Constants::tick);
79 move->setEndValue(QPoint(0, 0));
79 } 80 }
80 81
81 return eating; 82 return eating;
@@ -138,12 +139,10 @@ void Actor::move(Actor::Movement direction)
138 break; 139 break;
139 } 140 }
140 141
141 qDebug() << __FILE__ << "Move from" << pos() - endpos << "to" << (pos()) << "(" << endpos << ")";
142 for(int i = 0; i < m_moving->animationCount(); ++i) 142 for(int i = 0; i < m_moving->animationCount(); ++i)
143 { 143 {
144 QPropertyAnimation *move = dynamic_cast<QPropertyAnimation *>(m_moving->animationAt(i)); 144 QPropertyAnimation *move = dynamic_cast<QPropertyAnimation *>(m_moving->animationAt(i));
145 move->setStartValue(QPoint(0, 0) - endpos); 145 move->setStartValue(QPoint(0, 0) - endpos);
146 move->setEndValue(QPoint(0, 0));
147 } 146 }
148 setPos(pos() + endpos); 147 setPos(pos() + endpos);
149 148
diff --git a/pacman-c++/bonuspoint.cpp b/pacman-c++/bonuspoint.cpp
index 0517c64..eedb796 100644
--- a/pacman-c++/bonuspoint.cpp
+++ b/pacman-c++/bonuspoint.cpp
@@ -1,6 +1,5 @@
1#include "bonuspoint.h" 1#include "bonuspoint.h"
2#include "constants.h" 2#include "constants.h"
3#include <QDebug>
4 3
5#define BONUSPOINTS_NUM_SPRITES 4 4#define BONUSPOINTS_NUM_SPRITES 4
6 5
diff --git a/pacman-c++/constants.h b/pacman-c++/constants.h
index f0e7903..3d78d1d 100644
--- a/pacman-c++/constants.h
+++ b/pacman-c++/constants.h
@@ -34,15 +34,17 @@ namespace Transmission
34 typedef unsigned int field_t; 34 typedef unsigned int field_t;
35 typedef unsigned int mask_t; 35 typedef unsigned int mask_t;
36 36
37 const field_t none = 0;
37 const field_t block = (1 << 3); 38 const field_t block = (1 << 3);
38 const field_t bonuspoint = (1 << 4); 39 const field_t point = (1 << 4);
39 const field_t pacman = (1 << 5); 40 const field_t bonuspoint = (1 << 5);
41 const field_t pacman = (1 << 6);
40 42
41 const field_t direction_none = 0; 43 const field_t direction_none = 0;
42 const field_t direction_left = (1 << 6); 44 const field_t direction_left = (1 << 7);
43 const field_t direction_right = (1 << 7); 45 const field_t direction_right = (1 << 8);
44 const field_t direction_up = (1 << 8); 46 const field_t direction_up = (1 << 9);
45 const field_t direction_down = (1 << 9); 47 const field_t direction_down = (1 << 10);
46 48
47 const mask_t color_mask = Color::none | Color::red | Color::blue | Color::green; 49 const mask_t color_mask = Color::none | Color::red | Color::blue | Color::green;
48 const mask_t type_mask = block | bonuspoint; 50 const mask_t type_mask = block | bonuspoint;
diff --git a/pacman-c++/mainwidget.cpp b/pacman-c++/mainwidget.cpp
index 6ee7b7a..d0b2ad7 100644
--- a/pacman-c++/mainwidget.cpp
+++ b/pacman-c++/mainwidget.cpp
@@ -3,6 +3,7 @@
3#include "actor.h" 3#include "actor.h"
4#include "block.h" 4#include "block.h"
5#include "bonuspoint.h" 5#include "bonuspoint.h"
6#include "point.h"
6#include "constants.h" 7#include "constants.h"
7 8
8// temporary 9// temporary
@@ -18,7 +19,7 @@ Transmission::map_t createDummyMap()
18 for (unsigned int y = 0; y < Constants::map_size.height; ++y) 19 for (unsigned int y = 0; y < Constants::map_size.height; ++y)
19 { 20 {
20 Transmission::field_t &cur = map[x][y]; 21 Transmission::field_t &cur = map[x][y];
21 cur = 0; 22 cur = Transmission::none;
22 } 23 }
23 } 24 }
24 25
@@ -189,6 +190,16 @@ Transmission::map_t createDummyMap()
189 map[17][15] |= Transmission::pacman; 190 map[17][15] |= Transmission::pacman;
190 map[17][15] |= Transmission::direction_left; 191 map[17][15] |= Transmission::direction_left;
191 192
193 for (unsigned int x = 0; x < Constants::map_size.width; ++x)
194 {
195 for (unsigned int y = 0; y < Constants::map_size.height; ++y)
196 {
197 Transmission::field_t &cur = map[x][y];
198 if (cur == Transmission::none)
199 cur |= Transmission::point;
200 }
201 }
202
192 return map; 203 return map;
193} 204}
194 205
@@ -275,7 +286,7 @@ void MainWidget::updateMap(const Transmission::map_t& map)
275 for (unsigned int y = 0; y < Constants::map_size.height; ++y) 286 for (unsigned int y = 0; y < Constants::map_size.height; ++y)
276 { 287 {
277 const Transmission::field_t &cur = map[x][y]; 288 const Transmission::field_t &cur = map[x][y];
278 if (cur == 0) 289 if (cur == Transmission::none)
279 continue; 290 continue;
280 //qDebug() << "not 0 at x=" << x << ", y=" << y << ", val=" << cur; 291 //qDebug() << "not 0 at x=" << x << ", y=" << y << ", val=" << cur;
281 292
@@ -302,6 +313,8 @@ void MainWidget::updateMap(const Transmission::map_t& map)
302 } 313 }
303 else if (cur & Transmission::bonuspoint) 314 else if (cur & Transmission::bonuspoint)
304 item = new BonusPoint(); 315 item = new BonusPoint();
316 else if (cur & Transmission::point)
317 item = new Point();
305 else if (cur & Transmission::pacman) 318 else if (cur & Transmission::pacman)
306 { 319 {
307 Actor *actor = m_actors.value(color, NULL); 320 Actor *actor = m_actors.value(color, NULL);
diff --git a/pacman-c++/pacman.pro b/pacman-c++/pacman.pro
index 6282c5d..68d1be9 100644
--- a/pacman-c++/pacman.pro
+++ b/pacman-c++/pacman.pro
@@ -5,7 +5,8 @@ SOURCES += pixmapitem.cpp \
5 block.cpp \ 5 block.cpp \
6 client.cpp \ 6 client.cpp \
7 bonuspoint.cpp \ 7 bonuspoint.cpp \
8 mainwidget.cpp 8 mainwidget.cpp \
9 point.cpp
9HEADERS += pixmapitem.h \ 10HEADERS += pixmapitem.h \
10 actor.h \ 11 actor.h \
11 animationmanager.h \ 12 animationmanager.h \
@@ -13,7 +14,8 @@ HEADERS += pixmapitem.h \
13 client.h \ 14 client.h \
14 bonuspoint.h \ 15 bonuspoint.h \
15 mainwidget.h \ 16 mainwidget.h \
16 constants.h 17 constants.h \
18 point.h
17RESOURCES += pacman.qrc 19RESOURCES += pacman.qrc
18 20
19OBJECTS_DIR = .obj 21OBJECTS_DIR = .obj
diff --git a/pacman-c++/pics/points.png b/pacman-c++/pics/points.png
index 7fff18d..8883588 100644
--- a/pacman-c++/pics/points.png
+++ b/pacman-c++/pics/points.png
Binary files differ
diff --git a/pacman-c++/point.cpp b/pacman-c++/point.cpp
new file mode 100644
index 0000000..8837bba
--- /dev/null
+++ b/pacman-c++/point.cpp
@@ -0,0 +1,17 @@
1#include "point.h"
2#include "constants.h"
3
4namespace
5{
6 QPixmap *pixmap = NULL;
7}
8
9Point::Point(QGraphicsItem *parent)
10 : PixmapItem(parent)
11{
12 if (pixmap == NULL)
13 pixmap = new QPixmap(":/points");
14 setPixmap(*pixmap);
15
16 //setSprite(rand * 20 + Constants::sprite_margin, Constants::sprite_margin, Constants::field_size.width, Constants::field_size.height);
17}
diff --git a/pacman-c++/point.h b/pacman-c++/point.h
new file mode 100644
index 0000000..847daed
--- /dev/null
+++ b/pacman-c++/point.h
@@ -0,0 +1,14 @@
1#ifndef POINT_H
2#define SPOINT_H
3
4#include "pixmapitem.h"
5
6class Point
7 : public PixmapItem
8{
9public:
10 Point(QGraphicsItem *parent=0);
11 virtual ~Point() {};
12};
13
14#endif // POINT_H