2 * Copyright 2007-2008 Thomas Gallinari <tg8187@yahoo.fr>
3 * Copyright 2007-2008 Alexandre Galinier <alex.galinier@hotmail.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "elementitem.h"
25 #include "ghostitem.h"
26 #include "kapmanitem.h"
28 #include <QGraphicsScene>
30 #include <KPixmapCache>
31 #include <KSvgRenderer>
35 * @brief This class contains all the Game elements to be drawn on the screen by the GameView instance.
37 class GameScene
: public QGraphicsScene
{
43 /** The Game instance */
46 /** The KapmanItem to be drawn */
47 KapmanItem
* m_kapmanItem
;
49 /** The MazeItem to be drawn */
52 /** The GhostItem of each Ghost to be drawn */
53 QList
<GhostItem
*> m_ghostItems
;
55 /** The ElementItem to be drawn (each Pill and Energizers) */
56 ElementItem
*** m_elementItems
;
58 /** The Bonus ElementItem */
59 ElementItem
* m_bonusItem
;
61 /** A list with labels to display when a ghost or a bonus is eaten */
62 QList
<QGraphicsTextItem
*> m_wonPointsLabels
;
64 /** The labels to be displayed during the game */
65 QGraphicsTextItem
* m_introLabel
;
66 QGraphicsTextItem
* m_introLabel2
;
67 QGraphicsTextItem
* m_newLevelLabel
;
68 QGraphicsTextItem
* m_scoreLabel
;
69 QGraphicsTextItem
* m_livesLabel
;
70 QGraphicsTextItem
* m_levelLabel
;
71 QGraphicsTextItem
* m_pauseLabel
;
73 /** The pixmap cache */
74 KPixmapCache
* m_cache
;
76 /** The SVG renderer */
77 KSvgRenderer
* m_renderer
;
85 * Creates a new GameScene instance.
86 * @param p_game the Game instance whose elements must be contained in the GameScene in order to be drawn
88 GameScene(Game
* p_game
);
91 * Deletes the Game instance.
96 * @return the Game instance
98 Game
* getGame() const;
101 * Loads the game theme.
108 * Updates the elements to be drawn on Game introduction.
109 * @param p_newLevel true a new level has begun, false otherwise
111 void intro(const bool p_newLevel
);
114 * Updates the elements to be drawn when the Game starts.
119 * Updates the elements to be drawn considering the Game state (paused or running).
120 * @param p_pause if true the Game has been paused, if false the Game has been resumed
121 * @param p_fromUser if true the Game has been paused due to an action from the user
123 void setPaused(const bool p_pause
, const bool p_fromUser
);
126 * Removes the Element at the given coordinates from the GameScene.
127 * @param p_wonPoints value of the won Points, used when a ghost or a Bonus is eaten
128 * @param p_x x-coordinate of the Element
129 * @param p_y y-coordinate of the Element
131 void hideElement(const qreal p_x
, const qreal p_y
);
134 * Displays the Bonus.
139 * Remove the Bonus from the GameScene.
144 * Upadates the Game information labels.
145 * @param p_info the type of the information to be updated
147 void updateInfo(const Game::InformationTypes p_info
);
150 * Display won Points on the scene when a Bonus or a Ghosts is eaten
151 * @param p_wonPoints the value to display
152 * @param p_xPos the position of the eaten element on X axis
153 * @param p_yPos the position of the eaten element on Y axis
155 void displayPoints(long p_wonPoints
, qreal p_xPos
, qreal p_yPos
);
158 * Hide the first label in the list of won points labels
163 * Update theme id elements.
168 * Update theme properties.
170 void updateThemeProperties();