+/**************************************************************************
+ 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 "octopus.h"
#include "ship.h"
qsrand(QTime::currentTime().msec()+2); //+2 to avoid setting it to 1
+ //connect selecting to menu handling (only menu items selectable)
+
+ connect(this,SIGNAL(selectionChanged()),this,SLOT(menuClicked()));
+
}
-void SeaScene::setupMap(int ghosts, int rocks, int octopuses)
+void SeaScene::setupMap(int ghosts, int rocks, int octopuses, int octopusSpeed)
{
//empty the map
break;
QPixmap octopusPixmap (":/pix/tursas.png");
- Octopus * pOctopus = new Octopus(octopusPixmap,100);
+ Octopus * pOctopus = new Octopus(octopusPixmap,octopusSpeed);
pOctopus->setData(0,"octopus");
pOctopus->setPos(*pPosition);
addItem(pOctopus);
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()));
delete pPosition;
}
+void SeaScene::setupMap(Level level)
+{
+ setupMap(level.getNumberOfGhosts(),level.getNumberOfRocks(),level.getNumberOfOctopuses(),level.getOctopusSpeed());
+}
void SeaScene::spreadGhosts(int ghosts)
{
screenLitKeeper_.keepScreenLit(false);
}
}
+
+void SeaScene::vibrationActivate(bool on)
+{
+ emit vibrationActivated(on);
+}
+
+void SeaScene::menuClicked()
+{
+ QList<QGraphicsItem *> items = selectedItems();
+
+ //if nothing selected (selection was removed) do nothing
+
+ if (items.isEmpty())
+ return;
+
+ //Menu functions
+
+ QString menuitem = items.at(0)->data(0).toString();
+
+ if (menuitem == "restart game")
+ {
+
+ }
+
+ else if (menuitem == "restart level")
+ {
+
+ }
+
+ else if (menuitem == "vibration effects")
+ {
+
+ }
+
+ else if (menuitem == "about")
+ {
+
+ }
+
+
+ //Selection is just used to get notice of being clicked, removed after use
+
+ clearSelection();
+
+}
+
+void SeaScene::showMenu()
+{
+ menuItems_.show();
+}
+
+void::SeaScene::hideMenu()
+{
+ menuItems_.hide();
+}