SVN_SILENT made messages (.desktop file)
[kdegames.git] / killbots / scene.h
blob233233acce32b353a89e34bef572013b6b4d7c4b
1 /*
2 * Copyright 2007-2009 Parker Coates <parker.coates@gmail.com>
4 * This file is part of Killbots.
6 * Killbots is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
11 * Killbots is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Killbots. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef KILLBOTS_SCENE_H
21 #define KILLBOTS_SCENE_H
23 #include "engine.h"
24 #include "sprite.h"
26 class KGamePopupItem;
28 #include <QtCore/QTimeLine>
29 #include <QtGui/QGraphicsScene>
32 namespace Killbots
34 class GameStatusDisplayItem;
36 class Scene : public QGraphicsScene
38 Q_OBJECT
40 public: // functions
41 explicit Scene( QObject * parent = 0 );
42 virtual ~Scene();
44 void setAnimationSpeed( int speed );
46 void beginNewAnimationStage();
47 Sprite * createSprite( SpriteType type, QPoint position );
48 void slideSprite( Sprite * sprite, QPoint position );
49 void teleportSprite( Sprite * sprite, QPoint position );
50 void destroySprite( Sprite * sprite );
52 void startAnimation();
54 public slots:
55 void updateRound( int round );
56 void updateScore( int score );
57 void updateEnemyCount( int enemyCount );
58 void updateEnergy( int energy );
60 void showNewGameMessage();
61 void showRoundCompleteMessage();
62 void showBoardFullMessage();
63 void showGameOverMessage();
65 void doLayout();
66 void onNewGame( int rows, int columns, bool gameIncludesEnergy );
68 signals:
69 void animationStageDone();
70 void animationDone();
71 void clicked( int action );
73 protected: // functions
74 virtual void drawBackground( QPainter * painter, const QRectF & rect );
75 virtual void mouseMoveEvent( QGraphicsSceneMouseEvent * mouseEvent );
76 virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * mouseEvent );
78 private: // types
79 struct AnimationStage;
81 private: // functions
82 void startAnimationStage();
83 void updateSpritePos( Sprite * sprite ) const;
84 HeroAction getMouseDirection( QGraphicsSceneMouseEvent * event );
85 void showUnqueuedMessage( const QString & message, int timeOut = 3000 );
86 void showQueuedMessage( const QString & message );
88 private slots:
89 void nextAnimationStage();
90 void animate( qreal value );
92 private: // data members
93 Sprite * m_hero;
94 QList<AnimationStage> m_stages;
96 QTimeLine m_timeLine;
98 KGamePopupItem * m_unqueuedPopup;
99 KGamePopupItem * m_queuedPopup;
101 GameStatusDisplayItem * m_roundDisplay;
102 GameStatusDisplayItem * m_scoreDisplay;
103 GameStatusDisplayItem * m_enemyCountDisplay;
104 GameStatusDisplayItem * m_energyDisplay;
106 QSize m_cellSize;
107 int m_rows;
108 int m_columns;
112 #endif