From 651a1bee1adc5318922d1b37b0cea11a65df71e2 Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 12 Apr 2011 18:08:02 +0200 Subject: make removal of items from scene delayed by one tick (looks better) all items are now derived from gameentity and gameentity is derived from pixmapitem: - this is naturally better - allows us to add a generic gameentity.color() --- pacman-c++/server.cpp | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'pacman-c++/server.cpp') diff --git a/pacman-c++/server.cpp b/pacman-c++/server.cpp index b0ac6f8..dd15934 100644 --- a/pacman-c++/server.cpp +++ b/pacman-c++/server.cpp @@ -83,21 +83,11 @@ invalid_direction: // // TODO: support actors eating each other - // old item - PixmapItem *oldItem = visualMap[mapPosition.x()][mapPosition.y()]; - if (oldItem != NULL) - { - /* set item to explicit empty - * and add actor that removed/has eaten that item - */ - if (oldItem->eaten()) - map[mapPosition.x()][mapPosition.y()] = Transmission::empty | actor->color(); - } - - // new item - PixmapItem *item = visualMap[newMapPosition.x()][newMapPosition.y()]; + /* check if there's an item at new location of actor */ + GameEntity *item = visualMap[newMapPosition.x()][newMapPosition.y()]; if (item != NULL && oldItem != item) { + qDebug() << "item at new actor location found"; if (!item->checkEnter(actor)) { /* movement invalid. e.g. move against wall */ @@ -105,11 +95,11 @@ invalid_direction: } else { - // apply actions of entering this field + /* apply actions of entering this field */ bool survive = item->enter(actor); if (!survive) { - //map[newMapPosition.x()][newMapPosition.y()] = Transmission::empty; + map[newMapPosition.x()][newMapPosition.y()] = Transmission::empty | actor->color(); } } } @@ -134,6 +124,9 @@ invalid_direction: map[newMapPosition.x()][newMapPosition.y()] |= Transmission::pacman | i.key() | Util::actorMovementToTransmission(i.value()); + /* DEBUG: uncomments to disable auto-movement */ + //m_actorMovements[i.key()] = Actor::None; + if (i.value() == Actor::None) { /* set actor to non-moving */ -- cgit v1.2.3