summaryrefslogtreecommitdiffstats
path: root/examples/statemachine/tankgame/mainwindow.h
blob: 40e1595b943bbfa4b395471f860eb3a358f34992 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QTime>

class QGraphicsScene;
class QStateMachine;
class QState;
class GameOverTransition;
class TankItem;
class MainWindow: public QMainWindow
{
    Q_OBJECT
    Q_PROPERTY(bool started READ started WRITE setStarted)
public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();

    void setStarted(bool b) { m_started = b; }
    bool started() const { return m_started; }

public slots:
    void addTank();
    void addRocket();
    void runStep();
    void gameOver();

signals:
    void mapFull();

private:
    void init();
    void addWall(const QRectF &wall);

    QGraphicsScene *m_scene;
    
    QStateMachine *m_machine;
    QState *m_runningState;
    GameOverTransition *m_gameOverTransition;

    QList<TankItem *> m_spawns;
    QTime m_time;
    
    bool m_started : 1;
};

#endif