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 +++++- pacman-c++/server.cpp | 2 +- pacman-c++/util.cpp | 3 --- 3 files changed, 6 insertions(+), 5 deletions(-) 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) diff --git a/pacman-c++/server.cpp b/pacman-c++/server.cpp index cc69f08..1c3caf9 100644 --- a/pacman-c++/server.cpp +++ b/pacman-c++/server.cpp @@ -41,7 +41,7 @@ bool Server::run() QTimer *timer2 = new QTimer(this); connect(timer2, SIGNAL(timeout()), this, SLOT(onRoundFinished())); timer2->start(3000); - / */ + // */ connect(this, SIGNAL(allPointsRemoved()), SLOT(onRoundFinished())); diff --git a/pacman-c++/util.cpp b/pacman-c++/util.cpp index fcc1aff..070c716 100644 --- a/pacman-c++/util.cpp +++ b/pacman-c++/util.cpp @@ -139,15 +139,12 @@ namespace Util void fillPoints(Transmission::map_t map, Transmission::field_t type) { /* auto place normal points*/ - int i =0; for (unsigned int x = 0; x < Constants::map_size.width; ++x) { for (unsigned int y = 0; y < Constants::map_size.height; ++y) { Transmission::field_t &cur = map[x][y]; if (cur == Transmission::none) { - if (++i > 10 ) continue; - cur = type; } else if (cur == Transmission::point) { cur = Transmission::none; -- cgit v1.2.3