summaryrefslogtreecommitdiffstats
path: root/pacman-c++
diff options
context:
space:
mode:
Diffstat (limited to 'pacman-c++')
-rw-r--r--pacman-c++/actor.h2
-rw-r--r--pacman-c++/block.h3
-rw-r--r--pacman-c++/bonuspoint.h1
-rw-r--r--pacman-c++/mainwidget.cpp25
-rw-r--r--pacman-c++/mainwidget.h8
-rw-r--r--pacman-c++/pixmapitem.h1
6 files changed, 24 insertions, 16 deletions
diff --git a/pacman-c++/actor.h b/pacman-c++/actor.h
index b9e050d..39ccb88 100644
--- a/pacman-c++/actor.h
+++ b/pacman-c++/actor.h
@@ -17,6 +17,8 @@ public:
17 }; 17 };
18 18
19 Actor(Color::Color color, QGraphicsItem *parent = 0); 19 Actor(Color::Color color, QGraphicsItem *parent = 0);
20 virtual ~Actor() {};
21
20 PixmapItem &getIcon(); 22 PixmapItem &getIcon();
21 Color::Color getColor() { return m_color; } 23 Color::Color getColor() { return m_color; }
22 24
diff --git a/pacman-c++/block.h b/pacman-c++/block.h
index 29ddd23..2354bc2 100644
--- a/pacman-c++/block.h
+++ b/pacman-c++/block.h
@@ -17,7 +17,10 @@ public:
17 Down = (1 << 3) 17 Down = (1 << 3)
18 }; 18 };
19 19
20public:
20 Block(Color::Color color, unsigned int neighbours = None, QGraphicsItem *parent = 0); 21 Block(Color::Color color, unsigned int neighbours = None, QGraphicsItem *parent = 0);
22 virtual ~Block() {};
23
21 void setNeighbours(unsigned int neighbours); 24 void setNeighbours(unsigned int neighbours);
22 25
23private: 26private:
diff --git a/pacman-c++/bonuspoint.h b/pacman-c++/bonuspoint.h
index b14f582..f0fc550 100644
--- a/pacman-c++/bonuspoint.h
+++ b/pacman-c++/bonuspoint.h
@@ -8,6 +8,7 @@ class BonusPoint
8{ 8{
9public: 9public:
10 BonusPoint(QGraphicsItem *parent=0); 10 BonusPoint(QGraphicsItem *parent=0);
11 virtual ~BonusPoint() {};
11}; 12};
12 13
13#endif // BONUSPOINT_H 14#endif // BONUSPOINT_H
diff --git a/pacman-c++/mainwidget.cpp b/pacman-c++/mainwidget.cpp
index fe1ba9c..bf049f2 100644
--- a/pacman-c++/mainwidget.cpp
+++ b/pacman-c++/mainwidget.cpp
@@ -39,17 +39,17 @@ Transmission::map_t createDummyMap()
39 map[2][1] |= Color::none ^ Transmission::block; 39 map[2][1] |= Color::none ^ Transmission::block;
40 40
41 map[4][3] |= Color::green ^ Transmission::block; 41 map[4][3] |= Color::green ^ Transmission::block;
42 42
43 map[5][3] |= Color::none ^ Transmission::block; 43 map[5][3] |= Color::none ^ Transmission::block;
44 map[6][3] |= Color::none ^ Transmission::block; 44 map[6][3] |= Color::none ^ Transmission::block;
45 map[7][3] |= Color::red ^ Transmission::block; 45 map[7][3] |= Color::red ^ Transmission::block;
46 46
47 map[7][5] |= Transmission::bonuspoint; 47 map[7][5] |= Transmission::bonuspoint;
48 48
49 map[5][5] |= Color::blue; 49 map[5][5] |= Color::blue;
50 map[5][5] |= Transmission::pacman; 50 map[5][5] |= Transmission::pacman;
51 map[5][5] |= Transmission::direction_left; 51 map[5][5] |= Transmission::direction_left;
52 52
53 return map; 53 return map;
54} 54}
55 55
@@ -63,7 +63,7 @@ MainWidget::MainWidget()
63void MainWidget::createGui() 63void MainWidget::createGui()
64{ 64{
65 setFocusPolicy(Qt::StrongFocus); 65 setFocusPolicy(Qt::StrongFocus);
66 66
67 QVBoxLayout *layout = new QVBoxLayout(this); 67 QVBoxLayout *layout = new QVBoxLayout(this);
68 QHBoxLayout *m_scoreLayout = new QHBoxLayout(); 68 QHBoxLayout *m_scoreLayout = new QHBoxLayout();
69 69
@@ -71,28 +71,28 @@ void MainWidget::createGui()
71 { 71 {
72 QGroupBox *scoreBoxI = new QGroupBox(QString("Spieler %1").arg(i), this); 72 QGroupBox *scoreBoxI = new QGroupBox(QString("Spieler %1").arg(i), this);
73 m_scoreLayout->addWidget(scoreBoxI); 73 m_scoreLayout->addWidget(scoreBoxI);
74 74
75 QGridLayout *playerLayout = new QGridLayout(); 75 QGridLayout *playerLayout = new QGridLayout();
76 scoreBoxI->setLayout(playerLayout); 76 scoreBoxI->setLayout(playerLayout);
77 77
78 playerLayout->addWidget(new QLabel("Rundenpunkte:", this), 0, 0); 78 playerLayout->addWidget(new QLabel("Rundenpunkte:", this), 0, 0);
79 playerLayout->addWidget(new QLabel("Gesamtpunkte:", this), 1, 0); 79 playerLayout->addWidget(new QLabel("Gesamtpunkte:", this), 1, 0);
80 80
81 playerLayout->addWidget(new QLabel("", this), 0, 1); 81 playerLayout->addWidget(new QLabel("", this), 0, 1);
82 playerLayout->addWidget(new QLabel("", this), 1, 1); 82 playerLayout->addWidget(new QLabel("", this), 1, 1);
83 83
84 m_playerScoreLayouts.append(playerLayout); 84 m_playerScoreLayouts.append(playerLayout);
85 } 85 }
86 86
87 m_scene = new QGraphicsScene(0, 0, Constants::map_size_pixel.width, Constants::map_size_pixel.height, this); 87 m_scene = new QGraphicsScene(0, 0, Constants::map_size_pixel.width, Constants::map_size_pixel.height, this);
88 m_scene->setBackgroundBrush(Qt::black); 88 m_scene->setBackgroundBrush(Qt::black);
89 89
90 QGraphicsView *window = new QGraphicsView(m_scene, this); 90 QGraphicsView *window = new QGraphicsView(m_scene, this);
91 window->setFrameStyle(0); 91 window->setFrameStyle(0);
92 window->setAlignment(Qt::AlignLeft | Qt::AlignTop); 92 window->setAlignment(Qt::AlignLeft | Qt::AlignTop);
93 //window->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 93 //window->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
94 //window->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 94 //window->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
95 95
96 layout->addLayout(m_scoreLayout); 96 layout->addLayout(m_scoreLayout);
97 layout->addWidget(window); 97 layout->addWidget(window);
98 98
@@ -119,7 +119,6 @@ void MainWidget::updateScore()
119 } 119 }
120} 120}
121 121
122
123void MainWidget::updateMap(const Transmission::map_t& map) 122void MainWidget::updateMap(const Transmission::map_t& map)
124{ 123{
125 for (unsigned int x = 0; x < Constants::map_size.width; ++x) 124 for (unsigned int x = 0; x < Constants::map_size.width; ++x)
@@ -130,7 +129,7 @@ void MainWidget::updateMap(const Transmission::map_t& map)
130 if (cur == 0) 129 if (cur == 0)
131 continue; 130 continue;
132 qDebug() << "not 0 at x=" << x << ", y=" << y << ", val=" << cur; 131 qDebug() << "not 0 at x=" << x << ", y=" << y << ", val=" << cur;
133 132
134 Color::Color color = static_cast<Color::Color>(cur & Transmission::color_mask); 133 Color::Color color = static_cast<Color::Color>(cur & Transmission::color_mask);
135 qDebug() << "col=" << color; 134 qDebug() << "col=" << color;
136 135
@@ -240,6 +239,6 @@ void MainWidget::keyReleaseEvent(QKeyEvent* event)
240 // current key got released 239 // current key got released
241 // if this is false, a key got released which has already 240 // if this is false, a key got released which has already
242 // been replaced by a different key, so this case is disregarded 241 // been replaced by a different key, so this case is disregarded
243 currentKey = 0; 242 currentKey = 0;
244 } 243 }
245} 244}
diff --git a/pacman-c++/mainwidget.h b/pacman-c++/mainwidget.h
index 0056669..36e5624 100644
--- a/pacman-c++/mainwidget.h
+++ b/pacman-c++/mainwidget.h
@@ -1,10 +1,12 @@
1#ifndef MAINWIDGET_H 1#ifndef MAINWIDGET_H
2#define MAINWIDGET_H 2#define MAINWIDGET_H
3 3
4#include "constants.h"
5#include <QtGui> 4#include <QtGui>
6#include <QtCore> 5#include <QtCore>
7 6
7#include "constants.h"
8#include "pixmapitem.h"
9
8class Actor; 10class Actor;
9 11
10class MainWidget 12class MainWidget
@@ -22,12 +24,12 @@ protected:
22 24
23private: 25private:
24 void createGui(); 26 void createGui();
25 27
26 void updateMap(const Transmission::map_t& map); 28 void updateMap(const Transmission::map_t& map);
27 29
28 void updateScore(); 30 void updateScore();
29 31
30 Transmission::map_t currentMap; 32 PixmapItem ** visualMap;
31 33
32 // data conversion 34 // data conversion
33 QPoint mapPositionToCoord(unsigned int x, unsigned int y); 35 QPoint mapPositionToCoord(unsigned int x, unsigned int y);
diff --git a/pacman-c++/pixmapitem.h b/pacman-c++/pixmapitem.h
index 8e7d4f0..35a6440 100644
--- a/pacman-c++/pixmapitem.h
+++ b/pacman-c++/pixmapitem.h
@@ -13,6 +13,7 @@ public:
13 PixmapItem(const QString &fileName, QGraphicsScene *scene); 13 PixmapItem(const QString &fileName, QGraphicsScene *scene);
14 PixmapItem(const QPixmap &pix, QGraphicsItem *parent = 0); 14 PixmapItem(const QPixmap &pix, QGraphicsItem *parent = 0);
15 PixmapItem(const QPixmap &pix, QGraphicsScene *scene); 15 PixmapItem(const QPixmap &pix, QGraphicsScene *scene);
16 virtual ~PixmapItem() {};
16 void setPixmap(const QPixmap &pix); 17 void setPixmap(const QPixmap &pix);
17 void setSprite(int x, int y, int width, int height); 18 void setSprite(int x, int y, int width, int height);
18 QSizeF size() const; 19 QSizeF size() const;