-
Notifications
You must be signed in to change notification settings - Fork 2
/
pieces.py
88 lines (81 loc) · 2.73 KB
/
pieces.py
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
import numpy as np
from piece import Piece
class I(Piece):
_color = '5FFBFD'
def __init__(self, coords):
super().__init__(coords)
# Initial position as defined in: https://tetris.wiki/SRS
self._grid = np.rot90(np.array(
[[False, False, False, False],
[True, True, True, True],
[False, False, False, False],
[False, False, False, False]]), k = -1
)
class J(Piece):
_color = '0029F5'
def __init__(self, coords):
super().__init__(coords)
# Initial position as defined in: https://tetris.wiki/SRS
self._grid = np.rot90(np.array(
[[True, False, False],
[True, True, True],
[False, False, False]]), k = -1
)
class L(Piece):
_color = 'F8AC3A'
def __init__(self, coords):
super().__init__(coords)
# Initial position as defined in: https://tetris.wiki/SRS
self._grid = np.rot90(np.array(
[[False, False, True],
[True, True, True],
[False, False, False]]), k = -1
)
class O(Piece):
_color = 'FFFC52'
def __init__(self, coords):
super().__init__(coords)
# Initial position as defined in: https://tetris.wiki/SRS
self._grid = np.rot90(np.array(
[[False, True, True, False],
[False, True, True, False],
[False, False, False, False]]), k = -1
)
def rotate_ccw(self):
# Does nothing to the piece
return self
# or return self, return grid, etc. depending on how we code the rest
def rotate_cw(self):
# Does nothing to the piece
return self
# or return self, return grid, etc. depending on how we code the rest
class S(Piece):
_color = '65F84B'
def __init__(self, coords):
super().__init__(coords)
# Initial position as defined in: https://tetris.wiki/SRS
self._grid = np.rot90(np.array(
[[False, True, True],
[True, True, False],
[False, False, False]]), k = -1
)
class T(Piece):
_color = '8D34F6'
def __init__(self, coords):
super().__init__(coords)
# Initial position as defined in: https://tetris.wiki/SRS
self._grid = np.rot90(np.array(
[[False, True, False],
[True, True, True],
[False, False, False]]), k = -1
)
class Z(Piece):
_color = 'F2361F'
def __init__(self, coords):
super().__init__(coords)
# Initial position as defined in: https://tetris.wiki/SRS
self._grid = np.rot90(np.array(
[[True, True, False],
[False, True, True],
[False, False, False]]), k = -1
)