-
Notifications
You must be signed in to change notification settings - Fork 1
/
mainwindow.h
62 lines (44 loc) · 1008 Bytes
/
mainwindow.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
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "snake.h"
#include "fruit.h"
#include "menu.h"
#include <QWidget>
#include <QGraphicsView>
#include <QTimer>
#include <QStackedLayout>
#include <QJsonObject>
class MainWindow : public QWidget
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow() override;
void keyPressEvent(QKeyEvent *event) override;
void readJSON(const QJsonObject &json);
void writeJSON(QJsonObject &json) const;
public slots:
void eatFruit();
void movement();
void loadFromJSON();
void saveToJSON();
void start();
signals:
void speedChanged(QString);
private:
void initializeHash();
QPoint checkFruit();
void endGame();
void winGame();
void showMenu();
QGraphicsView* view;
QGraphicsScene* scene;
Menu* menu;
QStackedLayout* stackedLayout;
Snake* snake;
Fruit* fruit;
QTimer* timer;
int time;
QHash<QPoint, bool> checkboard;
};
#endif // MAINWINDOW_H