1 /**************************************************************************
2 Ghosts Overboard - a game for 'Meego 1.2 Harmattan'
4 Copyright (C) 2011 Heli Hyvättinen
6 This file is part of Ghosts Overboard
8 Ghosts Overboard is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 **************************************************************************/
27 #include <QGraphicsScene>
28 #include<QGraphicsItemGroup>
29 #include "screenlitkeeper.h"
35 #include <policy/resource-set.h>
37 class SeaScene : public QGraphicsScene
41 explicit SeaScene(QObject *parent = 0);
45 void allGhostsPicked();
48 void vibrationActivated(bool on);
53 /*! Places all needed items for a level to (re)start.
54 Relies on the scene size to be explicitly set to a a value that will persist troughout play.
55 @param ghosts the number of ghosts to be placed on the map
56 @param rocks the number of rocks to be placed on the map
57 @param octopuses number of octopuses to be placed on the map
59 void setupMap(int ghosts, int rocks, int octopuses, int octopusSpeed);
61 void setupMap(Level level);
63 void spreadGhosts(int ghosts);
65 void removeGhost(QGraphicsItem * pGhost);
67 void ghostsDropped(int ghosts);
69 void pause (bool paused);
71 void vibrationActivate(bool);
73 void handleScreenTapped();
87 void setItemPointersNull();
91 void resourcesAvailable();
99 /*! Gives a pointer to a random position if a free one is found. Otherwise returns NULL.
100 The position is the upper left corner of a free 40x40 pixels slot.
103 QPointF* findRandomFreeSlot();
105 void createMenuItems();
106 void prepareForMenu(QGraphicsItem * pItem);
107 void createAboutBoxItems();
108 void createVictoryItems();
109 void createLevelCompletedItems();
111 const QString ghostImageFilename_;
112 const QString rockImageFilename_;
113 const QString octopusImageFilename_;
114 const QStringList shipImageFilenames_;
116 QList<QPointF> freeTiles_;
120 QList<QGraphicsItem*> movingItems_;
124 ScreenLitKeeper screenLitKeeper_;
129 QGraphicsTextItem * pPausetextItem_;
131 QGraphicsTextItem * pRestartLevelItem_;
132 QGraphicsTextItem * pRestartGameItem_;
133 QGraphicsTextItem * pSettingsItem_;
134 QGraphicsTextItem * pAboutItem_;
135 QGraphicsTextItem * pQuitItem_;
137 QGraphicsTextItem * pVictoryScoreItem_;
138 QGraphicsTextItem * pAboutBoxItem_;
139 QGraphicsTextItem * pVictoryCongratulationsItem_;
141 QGraphicsTextItem * pLevelCompletedItem_;
149 QAction* pVibrateAction_;
151 QAction* pPauseAction_;
155 QTimer autopauseTimer;
162 ResourcePolicy::ResourceSet * pResourceSet_;
163 bool vibrationAllowed_;