graphicsscene.h Example File
animation/sub-attaq/graphicsscene.h
#ifndef __GRAPHICSSCENE__H__
#define __GRAPHICSSCENE__H__
#include <QtWidgets/QGraphicsScene>
#include <QtCore/QSet>
#include <QtCore/QState>
class Boat;
class SubMarine;
class Torpedo;
class Bomb;
class PixmapItem;
class ProgressItem;
class TextInformationItem;
class QAction;
class GraphicsScene : public QGraphicsScene
{
Q_OBJECT
public:
enum Mode {
Big = 0,
Small
};
struct SubmarineDescription {
int type;
int points;
QString name;
};
struct LevelDescription {
int id;
QString name;
QList<QPair<int,int> > submarines;
};
GraphicsScene(int x, int y, int width, int height, Mode mode = Big);
qreal sealLevel() const;
void setupScene(QAction *newAction, QAction *quitAction);
void addItem(Bomb *bomb);
void addItem(Torpedo *torpedo);
void addItem(SubMarine *submarine);
void addItem(QGraphicsItem *item);
void clearScene();
signals:
void subMarineDestroyed(int);
void allSubMarineDestroyed(int);
private slots:
void onBombExecutionFinished();
void onTorpedoExecutionFinished();
void onSubMarineExecutionFinished();
private:
Mode mode;
ProgressItem *progressItem;
TextInformationItem *textInformationItem;
Boat *boat;
QSet<SubMarine *> submarines;
QSet<Bomb *> bombs;
QSet<Torpedo *> torpedos;
QVector<SubmarineDescription> submarinesData;
QHash<int, LevelDescription> levelsData;
friend class PauseState;
friend class PlayState;
friend class LevelState;
friend class LostState;
friend class WinState;
friend class WinTransition;
friend class UpdateScoreTransition;
};
#endif //__GRAPHICSSCENE__H__