-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpiece.h
More file actions
134 lines (123 loc) · 2.95 KB
/
piece.h
File metadata and controls
134 lines (123 loc) · 2.95 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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#include <bits/stdc++.h>
#include <deque>
struct ColorRGB{
int r, g, b;
};
ColorRGB T_COLOR = {153, 51, 153};
ColorRGB S_COLOR = {119, 179, 0};
ColorRGB O_COLOR = {255, 204, 0};
ColorRGB Z_COLOR = {204, 0, 0};
ColorRGB L_COLOR = {0, 0, 204};
ColorRGB J_COLOR = {255, 153, 0};
ColorRGB I_COLOR = {153, 204, 255};
class Piece{
protected:
int _size;
int _rotation;
int _posX = 0;
int _posY = 0;
int _id = 0;
ColorRGB _color = {100, 100, 100};
std::vector<std::vector<bool>> _mask;
std::vector<std::vector<bool>> _rotatedMasks[4];
void loadRotations();
public:
virtual ~Piece() = default;
void rotateR();
void rotateL();
void setPosX(int x);
void setPosY(int y);
void setRotation(int angle);
int getPosX();
int getPosY();
int getRotation();
int getSize();
int getId();
ColorRGB getColor();
bool getMaskAt(int i, int j);
void displayMask();
};
class TPiece: public Piece {
public:
TPiece(){
_color = T_COLOR;
_size = 3;
_id = (int)('T');
_mask = {{0, 1, 0},
{1, 1, 1},
{0, 0, 0}};
loadRotations();
}
};
class SPiece: public Piece {
public:
SPiece(){
_color = S_COLOR;
_size = 3;
_id = (int)('S');
_mask = {{0, 0, 0},
{0, 1, 1},
{1, 1, 0}};
loadRotations();
}
};
class OPiece: public Piece {
public:
OPiece(){
_color = O_COLOR;
_size = 2;
_id = (int)('O');
_mask = {{1, 1},
{1, 1}};
loadRotations();
}
};
class IPiece: public Piece {
public:
IPiece(){
_color = I_COLOR;
_size = 4;
_id = (int)('I');
_mask = {{0, 0, 0, 0},
{1, 1, 1, 1},
{0, 0, 0, 0},
{0, 0, 0, 0}};
loadRotations();
}
};
class LPiece: public Piece {
public:
LPiece(){
_color = L_COLOR;
_size = 3;
_id = (int)('L');
_mask = {{0, 0, 0},
{1, 0, 0},
{1, 1, 1}};
loadRotations();
}
};
class ZPiece: public Piece {
public:
ZPiece(){
_color = Z_COLOR;
_size = 3;
_id = (int)('Z');
_mask = {{0, 0, 0},
{1, 1, 0},
{0, 1, 1}};
loadRotations();
}
};
class JPiece: public Piece {
public:
JPiece(){
_color = J_COLOR;
_size = 3;
_id = (int)('J');
_mask = {{0, 0, 0},
{0, 0, 1},
{1, 1, 1}};
loadRotations();
}
};