-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.h
More file actions
55 lines (46 loc) · 1.28 KB
/
node.h
File metadata and controls
55 lines (46 loc) · 1.28 KB
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
#ifndef NODE_H
#define NODE_H
#include <QWidget>
#include "configure.h"
#include <QFrame>
#include <QDebug>
#include <QJsonArray>
class Node : public QWidget
{
Q_OBJECT
public:
explicit Node(Pos pos, QString styleSheet, QWidget *parent = nullptr);
void draw();
void move(Pos newPos);
Pos getPos();
void remove();
QJsonArray jsonPos();
void fromJson(QJsonArray array);
private:
QString styleSheet;
Pos pos;
QFrame* frame;
signals:
};
class SnakeNode: public Node{
using Node::Node;
};
class SnakeHeadNode: public SnakeNode{
public:
SnakeHeadNode(Pos pos, QWidget *parent = nullptr): SnakeNode(pos, QString("background-color: blue; border: 1px solid white"), parent){
};
};
class SnakeBodyNode: public SnakeNode{
public:
SnakeBodyNode(Pos pos, QWidget *parent = nullptr): SnakeNode(pos, QString("background-color: green; border: 1px solid white"), parent){
};
};
class WallNode: public Node{
public:
WallNode(Pos pos, QWidget *parent = nullptr): Node(pos, QString("background-color: grey"), parent){};
};
class FoodNode: public Node{
public:
FoodNode(Pos pos, QWidget *parent = nullptr): Node(pos, QString("background-color: red"), parent){};
};
#endif // NODE_H