From 11a1b82636ab75cb9d002712a3e0f353ad6b2579 Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 7 Apr 2011 04:02:55 +0200 Subject: add some sounds --- pacman-c++/mainwidget.cpp | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'pacman-c++/mainwidget.cpp') diff --git a/pacman-c++/mainwidget.cpp b/pacman-c++/mainwidget.cpp index d0b2ad7..73612af 100644 --- a/pacman-c++/mainwidget.cpp +++ b/pacman-c++/mainwidget.cpp @@ -1,11 +1,13 @@ #include "mainwidget.h" - #include "actor.h" #include "block.h" #include "bonuspoint.h" #include "point.h" #include "constants.h" +#include +#include + // temporary Transmission::map_t createDummyMap() { @@ -204,7 +206,7 @@ Transmission::map_t createDummyMap() } MainWidget::MainWidget() - : m_currentKey(0) + : m_currentKey(0), m_running(false) { visualMap.resize(Constants::map_size.width); for (int i=0; iplay(); +#endif } void MainWidget::createGui() @@ -321,7 +332,7 @@ void MainWidget::updateMap(const Transmission::map_t& map) if (actor == NULL) { //qDebug() << "new actor of col" << color; - actor = new Actor(color); + actor = new Actor(color, (color == Color::red)); //TODO: red = local for testing m_actors[color] = actor; m_scene->addItem(actor); actor->setPos(mapPositionToCoord(x, y)); @@ -403,6 +414,9 @@ Transmission::field_t MainWidget::translateKey(int key) void MainWidget::keyPressEvent(QKeyEvent* event) { + if (!m_running) + return; + QWidget::keyPressEvent(event); m_currentKey = translateKey(event->key()); @@ -436,6 +450,9 @@ void MainWidget::keyPressEvent(QKeyEvent* event) void MainWidget::keyReleaseEvent(QKeyEvent* event) { + if (!m_running) + return; + QWidget::keyReleaseEvent(event); Transmission::field_t releasedKey = translateKey(event->key()); if (releasedKey == m_currentKey) @@ -446,3 +463,8 @@ void MainWidget::keyReleaseEvent(QKeyEvent* event) m_currentKey = Transmission::direction_none; } } + +void MainWidget::startGame() +{ + m_running = true; +} -- cgit v1.2.3