From 5035ea3e5616578fc406998e7850c55e5f4d13a6 Mon Sep 17 00:00:00 2001 From: totycro Date: Wed, 6 Apr 2011 15:25:58 +0200 Subject: merge --- pacman-c++/actor.h | 2 ++ pacman-c++/block.h | 3 +++ pacman-c++/bonuspoint.h | 1 + pacman-c++/mainwidget.cpp | 25 ++++++++++++------------- pacman-c++/mainwidget.h | 8 +++++--- pacman-c++/pixmapitem.h | 1 + 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: }; Actor(Color::Color color, QGraphicsItem *parent = 0); + virtual ~Actor() {}; + PixmapItem &getIcon(); Color::Color getColor() { return m_color; } 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: Down = (1 << 3) }; +public: Block(Color::Color color, unsigned int neighbours = None, QGraphicsItem *parent = 0); + virtual ~Block() {}; + void setNeighbours(unsigned int neighbours); private: 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 { public: BonusPoint(QGraphicsItem *parent=0); + virtual ~BonusPoint() {}; }; #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() map[2][1] |= Color::none ^ Transmission::block; map[4][3] |= Color::green ^ Transmission::block; - + map[5][3] |= Color::none ^ Transmission::block; map[6][3] |= Color::none ^ Transmission::block; map[7][3] |= Color::red ^ Transmission::block; - + map[7][5] |= Transmission::bonuspoint; - + map[5][5] |= Color::blue; map[5][5] |= Transmission::pacman; map[5][5] |= Transmission::direction_left; - + return map; } @@ -63,7 +63,7 @@ MainWidget::MainWidget() void MainWidget::createGui() { setFocusPolicy(Qt::StrongFocus); - + QVBoxLayout *layout = new QVBoxLayout(this); QHBoxLayout *m_scoreLayout = new QHBoxLayout(); @@ -71,28 +71,28 @@ void MainWidget::createGui() { QGroupBox *scoreBoxI = new QGroupBox(QString("Spieler %1").arg(i), this); m_scoreLayout->addWidget(scoreBoxI); - + QGridLayout *playerLayout = new QGridLayout(); scoreBoxI->setLayout(playerLayout); playerLayout->addWidget(new QLabel("Rundenpunkte:", this), 0, 0); playerLayout->addWidget(new QLabel("Gesamtpunkte:", this), 1, 0); - + playerLayout->addWidget(new QLabel("", this), 0, 1); playerLayout->addWidget(new QLabel("", this), 1, 1); m_playerScoreLayouts.append(playerLayout); } - + m_scene = new QGraphicsScene(0, 0, Constants::map_size_pixel.width, Constants::map_size_pixel.height, this); m_scene->setBackgroundBrush(Qt::black); - + QGraphicsView *window = new QGraphicsView(m_scene, this); window->setFrameStyle(0); window->setAlignment(Qt::AlignLeft | Qt::AlignTop); //window->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); //window->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - + layout->addLayout(m_scoreLayout); layout->addWidget(window); @@ -119,7 +119,6 @@ void MainWidget::updateScore() } } - void MainWidget::updateMap(const Transmission::map_t& map) { for (unsigned int x = 0; x < Constants::map_size.width; ++x) @@ -130,7 +129,7 @@ void MainWidget::updateMap(const Transmission::map_t& map) if (cur == 0) continue; qDebug() << "not 0 at x=" << x << ", y=" << y << ", val=" << cur; - + Color::Color color = static_cast(cur & Transmission::color_mask); qDebug() << "col=" << color; @@ -240,6 +239,6 @@ void MainWidget::keyReleaseEvent(QKeyEvent* event) // current key got released // if this is false, a key got released which has already // been replaced by a different key, so this case is disregarded - currentKey = 0; + currentKey = 0; } } 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 @@ #ifndef MAINWIDGET_H #define MAINWIDGET_H -#include "constants.h" #include #include +#include "constants.h" +#include "pixmapitem.h" + class Actor; class MainWidget @@ -22,12 +24,12 @@ protected: private: void createGui(); - + void updateMap(const Transmission::map_t& map); void updateScore(); - Transmission::map_t currentMap; + PixmapItem ** visualMap; // data conversion 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: PixmapItem(const QString &fileName, QGraphicsScene *scene); PixmapItem(const QPixmap &pix, QGraphicsItem *parent = 0); PixmapItem(const QPixmap &pix, QGraphicsScene *scene); + virtual ~PixmapItem() {}; void setPixmap(const QPixmap &pix); void setSprite(int x, int y, int width, int height); QSizeF size() const; -- cgit v1.2.3