-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathshape.py
64 lines (50 loc) · 2.53 KB
/
shape.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
import numpy as np
class Shape:
def __init__(self, rotations):
self.rotations = rotations
self.rotations_count = len(rotations)
def get_matrix_with_offset(self, rotation, offset):
return offset + self.rotations[rotation]
def generate_shapes():
# shape i
shape_i_rot1 = np.array([[1, 0], [1, 1], [1, 2], [1, 3]], np.int32)
shape_i_rot2 = np.array([[0, 1], [1, 1], [2, 1], [3, 1]], np.int32)
shape_i = Shape(np.array([shape_i_rot1, shape_i_rot2]))
# shape l
shape_l_rot1 = np.array([[1, 0], [1, 1], [1, 2], [2, 2]], np.int32)
shape_l_rot2 = np.array([[0, 2], [1, 2], [2, 2], [2, 1]], np.int32)
shape_l_rot3 = np.array([[1, 0], [2, 0], [2, 1], [2, 2]], np.int32)
shape_l_rot4 = np.array([[0, 3], [0, 2], [1, 2], [2, 2]], np.int32)
shape_l = Shape(np.array([shape_l_rot1, shape_l_rot2, shape_l_rot3, shape_l_rot4]))
# shape j
shape_j_rot1 = np.array([[2, 0], [2, 1], [2, 2], [1, 2]], np.int32)
shape_j_rot2 = np.array([[0, 1], [1, 1], [2, 1], [2, 2]], np.int32)
shape_j_rot3 = np.array([[3, 0], [2, 0], [2, 1], [2, 2]], np.int32)
shape_j_rot4 = np.array([[0, 1], [0, 2], [1, 2], [2, 2]], np.int32)
shape_j = Shape(np.array([shape_j_rot1, shape_j_rot2, shape_j_rot3, shape_j_rot4]))
# shape_s
shape_s_rot1 = np.array([[0, 2], [1, 2], [1, 1], [2, 1]], np.int32)
shape_s_rot2 = np.array([[1, 0], [1, 1], [2, 1], [2, 2]], np.int32)
shape_s = Shape(np.array([shape_s_rot1, shape_s_rot2]))
# shape_z
shape_z_rot1 = np.array([[0, 1], [1, 1], [1, 2], [2, 2]], np.int32)
shape_z_rot2 = np.array([[2, 0], [2, 1], [1, 1], [1, 2]], np.int32)
shape_z = Shape(np.array([shape_z_rot1, shape_z_rot2]))
# shape_t
shape_t_rot1 = np.array([[0, 2], [1, 2], [2, 2], [1, 1]], np.int32)
shape_t_rot2 = np.array([[2, 0], [2, 1], [2, 2], [1, 1]], np.int32)
shape_t_rot3 = np.array([[0, 1], [1, 1], [2, 1], [1, 2]], np.int32)
shape_t_rot4 = np.array([[1, 0], [1, 1], [1, 2], [2, 1]], np.int32)
shape_t = Shape(np.array([shape_t_rot1, shape_t_rot2, shape_t_rot3, shape_t_rot4]))
shape_o_rot1 = np.array([[1, 1], [1, 2], [2, 1], [2, 2]], np.int32)
shape_o = Shape(np.array([shape_o_rot1]))
return list([shape_i, shape_l, shape_j, shape_s, shape_z, shape_t, shape_o])
def generate_colours():
RED = [255, 0, 0]
GREEN = [0, 255, 0]
YELLOW = [204, 204, 0]
BLUE = [0, 0, 255]
OLIVE = [128, 128, 0]
ORANGE = [255, 165, 0]
WHITE = [125, 125, 125]
return list([WHITE, BLUE, RED, GREEN, ORANGE, GREEN, YELLOW, OLIVE])