Qctopuses now drop the ghosts when hitting the ship
authorHeli Hyvättinen <heli.hyvattinen@kymp.net>
Tue, 21 Jun 2011 07:41:55 +0000 (10:41 +0300)
committerHeli Hyvättinen <heli.hyvattinen@kymp.net>
Tue, 21 Jun 2011 07:41:55 +0000 (10:41 +0300)
seascene.cpp
ship.cpp
timercontrolledgraphicspixmapobject.h

index 2986f2d..71304d0 100644 (file)
@@ -88,7 +88,7 @@ void SeaScene::setupMap(int ghosts, int rocks, int octopuses)
 
     //spread the octopuses
 
-    QList<Octopus*> octopuses;
+    QList <Octopus*> octopusList;
 
     for (int i=0; i < octopuses; i++)
     {
@@ -107,7 +107,7 @@ void SeaScene::setupMap(int ghosts, int rocks, int octopuses)
     movingItems_.append(pOctopus);
     connect(this,SIGNAL(pauseOn()),pOctopus,SLOT(stopMoving()));
     connect(this,SIGNAL(pauseOff()),pOctopus,SLOT(startMoving()));
-    octopuses.append(pOctopus);
+    octopusList.append(pOctopus);
     delete pPosition;
 
     }
@@ -147,7 +147,7 @@ void SeaScene::setupMap(int ghosts, int rocks, int octopuses)
     movingItems_.append(pShip);
     connect(this,SIGNAL(pauseOn()),pShip,SLOT(stopMoving()));
     connect(this,SIGNAL(pauseOff()),pShip,SLOT(startMoving()));
-    foreach (Octopus* pOctopus, octopuses)
+    foreach (Octopus* pOctopus, octopusList)
     {
         connect(pOctopus,SIGNAL(droppingGhosts()),pShip,SLOT(dropAllGhosts()));
     }
index 1e80194..040e776 100644 (file)
--- a/ship.cpp
+++ b/ship.cpp
@@ -26,9 +26,10 @@ bool Ship::handleCollisions()
         if (type == "rock" || type == "octopus")
         {
             // drop all ghosts when hitting an obstacle
-            emit droppingGhosts(ghostsAboard_);
-            ghostsAboard_ = 0;
-            updateShipImage();
+
+            dropAllGhosts();
+
+            //go back to old position
 
             return false;
         }
@@ -46,6 +47,9 @@ bool Ship::handleCollisions()
         }
 
     }
+
+
+    return true; //execution can never reach here, this is just to stop the compiler from complaining
 }
 
 void Ship::updateShipImage()
@@ -56,6 +60,9 @@ void Ship::updateShipImage()
 
 void Ship::dropAllGhosts()
 {
-//TODO
+
+    emit droppingGhosts(ghostsAboard_);
+    ghostsAboard_ = 0;
+    updateShipImage();
 }
 
index da179f7..0e7a426 100644 (file)
@@ -5,7 +5,7 @@
 #include <QGraphicsPixmapItem>
 #include <QTimer>
 
-class TimerControlledGraphisPixmapObject : public QObject, public QGraphicsPixmapItem
+class TimerControlledGraphicsPixmapObject : public QObject, public QGraphicsPixmapItem
 {
     Q_OBJECT
 public: