From eaf133fd08c9708fe718ef47451bed7ea803a46a Mon Sep 17 00:00:00 2001 From: totycro Date: Tue, 19 Apr 2011 21:56:37 +0200 Subject: Added rounds rounds will end when all points are removed TODO: end round when a pacman gets eaten --- pacman-c++/sceneholder.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'pacman-c++/sceneholder.cpp') diff --git a/pacman-c++/sceneholder.cpp b/pacman-c++/sceneholder.cpp index dace711..2fcfb37 100644 --- a/pacman-c++/sceneholder.cpp +++ b/pacman-c++/sceneholder.cpp @@ -73,8 +73,9 @@ void SceneHolder::updateMap(const Transmission::map_t& map, const unsigned int x } /* an item must be removed by an actor */ - if (actor == NULL) + if (actor == NULL) { Q_ASSERT(false); + } oldItem->onDie(actor); /* register item for removal in next update */ @@ -132,9 +133,11 @@ void SceneHolder::updateMap(const Transmission::map_t& map, const unsigned int x m_actors[color] = actor; addItem(actor); actor->setPos(mapPositionToCoord(x, y)); + qDebug() << endl << "create act " << endl; } else { + qDebug() << endl << "act has pnts: " << actor->getRoundPoints() << actor->getGamePoints() << endl; Actor::Movement direction = Util::transmissionMovementToActor( cur & Transmission::direction_mask); /* WARNING: do NOT add actor to visualMap as visualMap-items may @@ -151,6 +154,7 @@ void SceneHolder::updateMap(const Transmission::map_t& map, const unsigned int x qDebug() << "[SceneUpdate] actor moves: color=" << color << "direction=" << direction << "newpos=" << QPoint(x, y); } + actor->setPos(mapPositionToCoord(x, y)); } if (cur & Transmission::empty) @@ -195,6 +199,9 @@ unsigned int SceneHolder::pointsLeft() void SceneHolder::decrementPoints() { --m_pointsLeft; + if (m_pointsLeft == 0) { + emit allPointsRemoved(); + } } void SceneHolder::setEatingOrder(QList &order) -- cgit v1.2.3 From ad0db492c213302a627bb4190458ae66834e82d7 Mon Sep 17 00:00:00 2001 From: totycro Date: Tue, 19 Apr 2011 22:01:41 +0200 Subject: removed some debug output --- pacman-c++/sceneholder.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'pacman-c++/sceneholder.cpp') diff --git a/pacman-c++/sceneholder.cpp b/pacman-c++/sceneholder.cpp index 2fcfb37..4d71a15 100644 --- a/pacman-c++/sceneholder.cpp +++ b/pacman-c++/sceneholder.cpp @@ -133,11 +133,9 @@ void SceneHolder::updateMap(const Transmission::map_t& map, const unsigned int x m_actors[color] = actor; addItem(actor); actor->setPos(mapPositionToCoord(x, y)); - qDebug() << endl << "create act " << endl; } else { - qDebug() << endl << "act has pnts: " << actor->getRoundPoints() << actor->getGamePoints() << endl; Actor::Movement direction = Util::transmissionMovementToActor( cur & Transmission::direction_mask); /* WARNING: do NOT add actor to visualMap as visualMap-items may -- cgit v1.2.3 From 7a5e71759c00b2c77f7ee3287c366dd1b48b81ca Mon Sep 17 00:00:00 2001 From: totycro Date: Tue, 19 Apr 2011 22:16:06 +0200 Subject: don't always call setPos --- pacman-c++/sceneholder.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'pacman-c++/sceneholder.cpp') diff --git a/pacman-c++/sceneholder.cpp b/pacman-c++/sceneholder.cpp index 4d71a15..37db691 100644 --- a/pacman-c++/sceneholder.cpp +++ b/pacman-c++/sceneholder.cpp @@ -152,7 +152,11 @@ void SceneHolder::updateMap(const Transmission::map_t& map, const unsigned int x qDebug() << "[SceneUpdate] actor moves: color=" << color << "direction=" << direction << "newpos=" << QPoint(x, y); } - actor->setPos(mapPositionToCoord(x, y)); + + QPoint distance = QPoint(x, y) - CoordToMapPosition(actor->pos().x(), actor->pos().y()); + if (distance.manhattanLength() > 1) { + actor->setPos(mapPositionToCoord(x, y)); + } } if (cur & Transmission::empty) -- cgit v1.2.3