-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathttcon.js
76 lines (71 loc) · 1.11 KB
/
ttcon.js
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
'use strict';
const COLS = 10;
const ROWS = 20;
const BLOCK_SIZE = 30;
const LINES_PER_LEVEL = 10;
const COLORS = [
'none',
'cyan',
'blue',
'orange',
'yellow',
'green',
'purple',
'red'
];
Object.freeze(COLORS);
const SHAPES = [
[],
[[0, 0, 0, 0], [1, 1, 1, 1], [0, 0, 0, 0], [0, 0, 0, 0]],
[[2, 0, 0], [2, 2, 2], [0, 0, 0]],
[[0, 0, 3], [3, 3, 3], [0, 0, 0]],
[[4, 4], [4, 4]],
[[0, 5, 5], [5, 5, 0], [0, 0, 0]],
[[0, 6, 0], [6, 6, 6], [0, 0, 0]],
[[7, 7, 0], [0, 7, 7], [0, 0, 0]]
];
Object.freeze(SHAPES);
const KEY = {
ESC: 27,
SPACE: 32,
LEFT: 37,
UP: 38,
RIGHT: 39,
DOWN: 40,
P: 80
}
Object.freeze(KEY);
const POINTS = {
SINGLE: 100,
DOUBLE: 300,
TRIPLE: 500,
TETRIS: 800,
SOFT_DROP: 1,
HARD_DROP: 2,
}
Object.freeze(POINTS);
const LEVEL = {
0: 800,
1: 720,
2: 630,
3: 550,
4: 470,
5: 380,
6: 300,
7: 220,
8: 130,
9: 100,
10: 80,
11: 80,
12: 80,
13: 70,
14: 70,
15: 70,
16: 50,
17: 50,
18: 50,
19: 30,
20: 30,
// 29+ is 20ms
}
Object.freeze(LEVEL);