Added a Level class
[ghostsoverboard] / ship.cpp
index 5c353d8..426cd63 100644 (file)
--- a/ship.cpp
+++ b/ship.cpp
@@ -1,3 +1,26 @@
+/**************************************************************************
+        Ghosts Overboard - a game for Maemo 5
+
+        Copyright (C) 2011  Heli Hyvättinen
+
+        This file is part of Ghosts Overboard
+
+        Ghosts Overboard is free software: you can redistribute it and/or modify
+        it under the terms of the GNU General Public License as published by
+        the Free Software Foundation, either version 2 of the License, or
+        (at your option) any later version.
+
+        This program is distributed in the hope that it will be useful,
+        but WITHOUT ANY WARRANTY; without even the implied warranty of
+        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+        GNU General Public License for more details.
+
+        You should have received a copy of the GNU General Public License
+        along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+**************************************************************************/
+
+
 #include "ship.h"
 #include <QDebug>
 
@@ -26,9 +49,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 +70,9 @@ bool Ship::handleCollisions()
         }
 
     }
+
+
+    return true; //execution can never reach here, this is just to stop the compiler from complaining
 }
 
 void Ship::updateShipImage()
@@ -53,3 +80,12 @@ void Ship::updateShipImage()
     int index = qBound(0,ghostsAboard_,shipImages_.length()-1);
     setPixmap(shipImages_.at(index));
 }
+
+void Ship::dropAllGhosts()
+{
+
+    emit droppingGhosts(ghostsAboard_);
+    ghostsAboard_ = 0;
+    updateShipImage();
+}
+