1 /**************************************************************************
2 Ghosts Overboard - a game for Maemo 5
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"
33 #include <QSystemDeviceInfo>
35 using namespace QtMobility;
37 class SeaScene : public QGraphicsScene
41 explicit SeaScene(QObject *parent = 0);
45 void allGhostsPicked();
48 void vibrationActivated(bool on);
49 void minimizeRequested();
50 void fullscreenRequested();
54 /*! Places all needed items for a level to (re)start.
55 Relies on the scene size to be explicitly set to a a value that will persist troughout play.
56 @param ghosts the number of ghosts to be placed on the map
57 @param rocks the number of rocks to be placed on the map
58 @param octopuses number of octopuses to be placed on the map
60 void setupMap(int ghosts, int rocks, int octopuses, int octopusSpeed);
62 void setupMap(Level level);
64 void spreadGhosts(int ghosts);
66 void removeGhost(QGraphicsItem * pGhost);
68 void ghostsDropped(int ghosts);
70 void pause (bool paused);
72 void vibrationActivate(bool);
74 void handleScreenTapped();
88 void createAboutBoxItems();
90 void createVictoryItems();
92 void setItemPointersNull();
96 void handleDeviceLocked(bool isLocked);
102 /*! Gives a pointer to a random position if a free one is found. Otherwise returns NULL.
103 The position is the upper left corner of a free 40x40 pixels slot.
106 QPointF* findRandomFreeSlot();
108 void createMenuItems();
109 void prepareForMenu(QGraphicsItem * pItem);
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_;
128 QGraphicsTextItem * pPausetextItem_;
130 QGraphicsTextItem * pRestartLevelItem_;
131 QGraphicsTextItem * pRestartGameItem_;
132 QGraphicsTextItem * pSettingsItem_;
133 QGraphicsTextItem * pAboutItem_;
134 QGraphicsTextItem * pQuitItem_;
135 QGraphicsTextItem * pMinimizeItem_;
137 QGraphicsTextItem * pVictoryCongratulationsItem_;
138 QGraphicsTextItem * pAboutBoxItem_;
140 QList<Level> levelList_;
145 QAction* pVibrateAction_;
147 QAction* pPauseAction_;
149 QTimer autopauseTimer;
151 QSystemDeviceInfo deviceInfo_;