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
28 #include <QtCore/QTimeLine>
29 #include <QtGui/QGraphicsScene>
34 class GameStatusDisplayItem
;
36 class Scene
: public QGraphicsScene
41 explicit Scene( QObject
* parent
= 0 );
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();
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();
66 void onNewGame( int rows
, int columns
, bool gameIncludesEnergy
);
69 void animationStageDone();
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
);
79 struct AnimationStage
;
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
);
89 void nextAnimationStage();
90 void animate( qreal value
);
92 private: // data members
94 QList
<AnimationStage
> m_stages
;
98 KGamePopupItem
* m_unqueuedPopup
;
99 KGamePopupItem
* m_queuedPopup
;
101 GameStatusDisplayItem
* m_roundDisplay
;
102 GameStatusDisplayItem
* m_scoreDisplay
;
103 GameStatusDisplayItem
* m_enemyCountDisplay
;
104 GameStatusDisplayItem
* m_energyDisplay
;