-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblock.h
More file actions
98 lines (91 loc) · 1.87 KB
/
block.h
File metadata and controls
98 lines (91 loc) · 1.87 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
#ifndef BLOCK_H_INCLUDED
#define BLOCK_H_INCLUDED
#include <array>
#include <string>
#include <vector>
#include <deque>
using namespace std;
namespace BlockKind {
constexpr int NONE = 0;
constexpr int WALL = 1;
constexpr int GHOST = 2;
constexpr int I = 3;
constexpr int O = 4;
constexpr int S = 5;
constexpr int Z = 6;
constexpr int J = 7;
constexpr int L = 8;
constexpr int T = 9;
};
constexpr int BLOCK_KIND_MAX = 7;
namespace ColorTable {
const array<basic_string<char>, 10> COLOR_TABLE = {
"\x1b[48;2;000;000;000m ", // 何もなし
"\x1b[48;2;127;127;127m__", // 壁
"\x1b[48;2;000;000;000m[]", // ゴースト
"\x1b[48;2;000;000;255m__", // I
"\x1b[48;2;000;255;000m__", // O
"\x1b[48;2;000;255;255m__", // S
"\x1b[48;2;255;000;000m__", // Z
"\x1b[48;2;255;000;255m__", // J
"\x1b[48;2;255;127;000m__", // L
"\x1b[48;2;255;255;000m__", // T
};
}
int random(int low, int high);
int randomBlock();
using BlockShape = vector<array<int,4>>;
using namespace BlockKind;
const BlockShape BLOCKS[BLOCK_KIND_MAX] = {
//I Block
{
{0, 0, 0, 0},
{0, 0, 0, 0},
{I, I, I, I},
{0, 0, 0, 0},
},
// O Block
{
{0, 0, 0, 0},
{0, O, O, 0},
{0, O, O, 0},
{0, 0, 0, 0},
},
// S Block
{
{0, 0, 0, 0},
{0, S, S, 0},
{S, S, 0, 0},
{0, 0, 0, 0},
},
// Z Block
{
{0, 0, 0, 0},
{Z, Z, 0, 0},
{0, Z, Z, 0},
{0, 0, 0, 0},
},
// J Block
{{
{0, 0, 0, 0},
{J, 0, 0, 0},
{J, J, J, 0},
{0, 0, 0, 0},
}},
// L Block
{
{0, 0, 0, 0},
{0, 0, L, 0},
{L, L, L, 0},
{0, 0, 0, 0},
},
// T Block
{
{0, 0, 0, 0},
{0, T, 0, 0},
{T, T, T, 0},
{0, 0, 0, 0},
},
};
deque<BlockShape> genBlock();
#endif