-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfield.h
More file actions
43 lines (38 loc) · 998 Bytes
/
field.h
File metadata and controls
43 lines (38 loc) · 998 Bytes
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
#ifndef FIELD_H
#define FIELD_H
#include <QWidget>
#include <QPair>
#include <QVector2D>
#include <QPainter>
#include <QPaintEvent>
#include <QKeyEvent>
#include <QDebug>
#include <QString>
#include <random>
#include <deque>
class Field : public QWidget
{
Q_OBJECT
public:
Field(QWidget *parent = nullptr, QPair<qint32, qint32> sizeField = {32,32}, qint32 sizeCell = 20);
protected:
void paintEvent(QPaintEvent *event);
void keyPressEvent(QKeyEvent * event);
void restart();
private:
bool redraw = true;
QColor backgroundColor = Qt::white;
QColor lineColor = Qt::black;
QColor eatColor = Qt::red;
QColor bodySnakeColor = Qt::green;
QColor headSnakeColor = Qt::darkGreen;
std::deque<QPair<qint32,qint32>> snake;
QPair<qint32,qint32> food;
QPair<qint32, qint32> sizeField;
QPair<qint32, qint32> snakeTile;
qint32 sizeCell;
QPair<qint32,qint32> ZERO = {-1,-1};
QVector<QVector<QColor>> color;
signals:
};
#endif // FIELD_H