6d932abcc9f59f0d870189ef806a16503e90790c
[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 "screenlitkeeper.h"
29 #include "level.h"
30
31 class SeaScene : public QGraphicsScene
32 {
33     Q_OBJECT
34 public:
35     explicit SeaScene(QObject *parent = 0);
36
37 signals:
38
39     void allGhostsPicked();
40     void pauseOn();
41     void pauseOff();
42     void vibrationActivated(bool on);
43
44 public slots:
45
46     /*! Places all needed items for a level to (re)start.
47     Relies on the scene size to be explicitly set to a a value that will persist troughout play.
48     @param ghosts the number of ghosts to be placed on the map
49     @param rocks the number of rocks to be placed on the map
50     @param octopuses number of octopuses to be placed on the map
51     */
52     void setupMap(int ghosts, int rocks, int octopuses, int octopusSpeed);
53
54     void setupMap(Level level);
55
56     void spreadGhosts(int ghosts);
57
58     void removeGhost(QGraphicsItem * pGhost);
59
60     void ghostsDropped(int ghosts);
61
62     void pause (bool paused);
63
64     void vibrationActivate(bool);
65
66 protected:
67
68     /*! Gives a pointer to a random position if a free one is found. Otherwise returns NULL.
69         The position is the upper left corner of a free 40x40 pixels slot.
70     */
71
72     QPointF* findRandomFreeSlot();
73
74     const QString ghostImageFilename_;
75     const QString rockImageFilename_;
76     const QString octopusImageFilename_;
77     const QStringList shipImageFilenames_;
78
79     QList<QPointF> freeTiles_;
80
81     int ghostsLeft_;
82
83     QList<QGraphicsItem*> movingItems_;
84
85     bool paused_;
86
87     ScreenLitKeeper screenLitKeeper_;
88
89
90
91
92 };
93
94 #endif // SEASCENE_H