7690d5776e0dde52f15265834e2c4ee9e12f7861
[ghostsoverboard] / seascene.h
1 /**************************************************************************
2         Ghosts Overboard - a game for Maemo 5
3
4         Copyright (C) 2011  Heli Hyvättinen
5
6         This file is part of Ghosts Overboard
7
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.
12
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.
17
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/>.
20
21 **************************************************************************/
22
23
24 #ifndef SEASCENE_H
25 #define SEASCENE_H
26
27 #include <QGraphicsScene>
28 #include<QGraphicsItemGroup>
29 #include "screenlitkeeper.h"
30 #include "level.h"
31
32 class SeaScene : public QGraphicsScene
33 {
34     Q_OBJECT
35 public:
36     explicit SeaScene(QObject *parent = 0);
37
38 signals:
39
40     void allGhostsPicked();
41     void pauseOn();
42     void pauseOff();
43     void vibrationActivated(bool on);
44
45 public slots:
46
47     /*! Places all needed items for a level to (re)start.
48     Relies on the scene size to be explicitly set to a a value that will persist troughout play.
49     @param ghosts the number of ghosts to be placed on the map
50     @param rocks the number of rocks to be placed on the map
51     @param octopuses number of octopuses to be placed on the map
52     */
53     void setupMap(int ghosts, int rocks, int octopuses, int octopusSpeed);
54
55     void setupMap(Level level);
56
57     void spreadGhosts(int ghosts);
58
59     void removeGhost(QGraphicsItem * pGhost);
60
61     void ghostsDropped(int ghosts);
62
63     void pause (bool paused);
64
65     void vibrationActivate(bool);
66
67     void menuClicked();
68
69
70 protected:
71
72     /*! Gives a pointer to a random position if a free one is found. Otherwise returns NULL.
73         The position is the upper left corner of a free 40x40 pixels slot.
74     */
75
76     QPointF* findRandomFreeSlot();
77
78     void createMenuItems();
79     void prepareForMenu(QGraphicsItem * pItem);
80
81     const QString ghostImageFilename_;
82     const QString rockImageFilename_;
83     const QString octopusImageFilename_;
84     const QStringList shipImageFilenames_;
85
86     QList<QPointF> freeTiles_;
87
88     int ghostsLeft_;
89
90     QList<QGraphicsItem*> movingItems_;
91
92     bool paused_;
93
94     ScreenLitKeeper screenLitKeeper_;
95
96
97     int menuItemCount_;
98
99     QGraphicsSimpleTextItem * pPausetextItem_;
100
101     QGraphicsSimpleTextItem * pRestartLevelItem_;
102     QGraphicsSimpleTextItem * pRestartGameItem_;
103     QGraphicsSimpleTextItem * pSettingsItem_;
104     QGraphicsSimpleTextItem * pAboutItem_;
105
106
107 };
108
109 #endif // SEASCENE_H