-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgame.h
89 lines (67 loc) · 1.6 KB
/
game.h
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#ifndef GAME_H
#define GAME_H
#include <QMainWindow>
#include <QAction>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QVector>
#include <QPointF>
#include <QPair>
#include <QComboBox>
#include <QLabel>
#include <QWidget>
class Cell;
class GameView;
class GameWindow;
class GameWindow : public QMainWindow
{
Q_OBJECT
public:
GameWindow(QWidget *parent = 0);
GameView *view;
QLabel *turnLabel;
void createSettingsWindow();
void createAboutGameWindow();
void createAboutDevsWindow();
private:
void setComboboxesColor(QComboBox *box, Qt::GlobalColor color);
QVector<Qt::GlobalColor> colorOrder;
QDialog *settings;
signals:
void changeColoures(QPair<Qt::GlobalColor, Qt::GlobalColor>);
public slots:
void changeTurnLabel(int turn);
};
class GameView : public QGraphicsView
{
Q_OBJECT
public:
GameView(QWidget *parent = 0);
void mouseMoveEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent *event);
QGraphicsScene *scene;
Cell *cell;
QPointF null_point;
void clearField();
QPair<Qt::GlobalColor, Qt::GlobalColor> colores;
protected:
static int a;
private:
int oldCrossNum;
bool check(int num);
bool check(Cell *c);
bool check(QPoint p);
bool gameIsOver();
QVector <Cell *> neighbours(Cell *c);
QVector <Cell *> neighbours(int num);
void loadPlayersColores();
int fieldSize;
int cellSize;
QVector<Cell*> cells;
int turn = 0;
signals:
void changeTurnLabel(int t);
public slots:
void changeColoures(QPair<Qt::GlobalColor, Qt::GlobalColor>);
};
#endif // GAME_H