diff options
Diffstat (limited to 'pacman-c++/sceneholder.cpp')
| -rw-r--r-- | pacman-c++/sceneholder.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/pacman-c++/sceneholder.cpp b/pacman-c++/sceneholder.cpp index 03abf7f..1610b7e 100644 --- a/pacman-c++/sceneholder.cpp +++ b/pacman-c++/sceneholder.cpp | |||
| @@ -150,11 +150,6 @@ void SceneHolder::updateMap(const Transmission::map_t& map, const unsigned int x | |||
| 150 | qDebug() << "[SceneUpdate] actor moves: color=" << color | 150 | qDebug() << "[SceneUpdate] actor moves: color=" << color |
| 151 | << "direction=" << direction << "newpos=" << QPoint(x, y); | 151 | << "direction=" << direction << "newpos=" << QPoint(x, y); |
| 152 | } | 152 | } |
| 153 | |||
| 154 | QPoint distance = QPoint(x, y) - CoordToMapPosition(actor->pos().x(), actor->pos().y()); | ||
| 155 | if (distance.manhattanLength() > 1) { | ||
| 156 | actor->setPos(mapPositionToCoord(x, y)); | ||
| 157 | } | ||
| 158 | } | 153 | } |
| 159 | 154 | ||
| 160 | if (cur & Transmission::empty) | 155 | if (cur & Transmission::empty) |
| @@ -213,6 +208,16 @@ QList<Color::Color> &SceneHolder::eatingOrder() | |||
| 213 | return m_eatingorder; | 208 | return m_eatingorder; |
| 214 | } | 209 | } |
| 215 | 210 | ||
| 211 | void SceneHolder::removeActors() | ||
| 212 | { | ||
| 213 | foreach(Actor *actor, m_actors) | ||
| 214 | { | ||
| 215 | removeItem(actor); | ||
| 216 | delete actor; | ||
| 217 | } | ||
| 218 | m_actors.clear(); | ||
| 219 | } | ||
| 220 | |||
| 216 | QPoint SceneHolder::mapPositionToCoord(unsigned int x, unsigned int y) | 221 | QPoint SceneHolder::mapPositionToCoord(unsigned int x, unsigned int y) |
| 217 | { | 222 | { |
| 218 | return QPoint(x * Constants::field_size.width, y * Constants::field_size.height); | 223 | return QPoint(x * Constants::field_size.width, y * Constants::field_size.height); |
| @@ -232,4 +237,3 @@ QPoint SceneHolder::CoordToMapPosition(QPoint point) | |||
| 232 | { | 237 | { |
| 233 | return CoordToMapPosition(point.x(), point.y()); | 238 | return CoordToMapPosition(point.x(), point.y()); |
| 234 | } | 239 | } |
| 235 | |||
