Updated the web page to reflect release of v.0.2.0
[ghostsoverboard] / seascene.cpp
index 0e4ff6c..764fea9 100644 (file)
@@ -1,5 +1,27 @@
+/**************************************************************************
+        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 "seascene.h"
-#include "timercontrolledtursas.h"
+#include "octopus.h"
 #include "ship.h"
 #include <QGraphicsPixmapItem>
 #include <QDebug>
@@ -31,7 +53,7 @@ SeaScene::SeaScene(QObject *parent) :
 
 }
 
-void SeaScene::setupMap(int ghosts, int rocks, int octopuses)
+void SeaScene::setupMap(int ghosts, int rocks, int octopuses, int octopusSpeed)
 {
     //empty the map
 
@@ -88,6 +110,7 @@ void SeaScene::setupMap(int ghosts, int rocks, int octopuses)
 
     //spread the octopuses
 
+    QList <Octopus*> octopusList;
 
     for (int i=0; i < octopuses; i++)
     {
@@ -98,7 +121,7 @@ void SeaScene::setupMap(int ghosts, int rocks, int octopuses)
             break;
 
     QPixmap octopusPixmap (":/pix/tursas.png");
-    TimerControlledTursas * pOctopus = new TimerControlledTursas (octopusPixmap,100);
+    Octopus * pOctopus = new Octopus(octopusPixmap,octopusSpeed);
     pOctopus->setData(0,"octopus");
     pOctopus->setPos(*pPosition);
     addItem(pOctopus);
@@ -106,6 +129,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()));
+    octopusList.append(pOctopus);
     delete pPosition;
 
     }
@@ -141,13 +165,22 @@ void SeaScene::setupMap(int ghosts, int rocks, int octopuses)
     addItem(pShip);
     connect(pShip,SIGNAL(pickingGhost(QGraphicsItem*)),this, SLOT(removeGhost(QGraphicsItem*)) );
     connect(pShip,SIGNAL(droppingGhosts(int)),this,SLOT(ghostsDropped(int)));
+    connect(this,SIGNAL(vibrationActivated(bool)),pShip,SLOT(setVibrationActivate(bool)));
     pShip->startMoving();
     movingItems_.append(pShip);
     connect(this,SIGNAL(pauseOn()),pShip,SLOT(stopMoving()));
     connect(this,SIGNAL(pauseOff()),pShip,SLOT(startMoving()));
+    foreach (Octopus* pOctopus, octopusList)
+    {
+        connect(pOctopus,SIGNAL(droppingGhosts()),pShip,SLOT(dropAllGhosts()));
+    }
     delete pPosition;
 }
 
+void SeaScene::setupMap(Level level)
+{
+    setupMap(level.getNumberOfGhosts(),level.getNumberOfRocks(),level.getNumberOfOctopuses(),level.getOctopusSpeed());
+}
 
 void SeaScene::spreadGhosts(int ghosts)
 {
@@ -280,3 +313,8 @@ void SeaScene::pause(bool paused)
             screenLitKeeper_.keepScreenLit(false);
         }
 }
+
+void SeaScene::vibrationActivate(bool on)
+{
+    emit vibrationActivated(on);
+}