From ebb3d3c754a50fccdc8f780d3297361925f33a85 Mon Sep 17 00:00:00 2001 From: totycro Date: Wed, 6 Apr 2011 16:08:19 +0200 Subject: Keep track of PixmapItems in client --- pacman-c++/mainwidget.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'pacman-c++/mainwidget.cpp') diff --git a/pacman-c++/mainwidget.cpp b/pacman-c++/mainwidget.cpp index bf049f2..a3acc45 100644 --- a/pacman-c++/mainwidget.cpp +++ b/pacman-c++/mainwidget.cpp @@ -56,6 +56,11 @@ Transmission::map_t createDummyMap() MainWidget::MainWidget() : currentKey(0) { + visualMap.resize(Constants::map_size.width); + for (int i=0; i(cur & Transmission::color_mask); qDebug() << "col=" << color; - PixmapItem *item = NULL; + PixmapItem* item = NULL; if (cur & Transmission::block) { unsigned int neighbours = Block::None; @@ -194,6 +199,12 @@ void MainWidget::updateMap(const Transmission::map_t& map) { m_scene->addItem(item); item->setPos(mapPositionToCoord(x, y)); + PixmapItem* oldItem = visualMap[x][y]; + visualMap[x][y] = item; + if (oldItem != NULL) { + m_scene->removeItem(item); + delete oldItem; + } } } } -- cgit v1.2.3