-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtetromino.py
88 lines (76 loc) · 2.48 KB
/
tetromino.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 random
tetromino_I_1 = [[0, 0, 0, 0],
[0, 0, 0, 0],
[1, 1, 1, 1],
[0, 0, 0, 0]]
tetromino_I_2 = [[0, 1, 0, 0],
[0, 1, 0, 0],
[0, 1, 0, 0],
[0, 1, 0, 0]]
tetromino_L_1 = [[0, 0, 0],
[2, 2, 2],
[2, 0, 0]]
tetromino_L_2 = [[2, 2, 0],
[0, 2, 0],
[0, 2, 0]]
tetromino_L_3 = [[0, 0, 2],
[2, 2, 2],
[0, 0, 0]]
tetromino_L_4 = [[0, 2, 0],
[0, 2, 0],
[0, 2, 2]]
tetromino_J_1 = [[0, 0, 0],
[3, 3, 3],
[0, 0, 3]]
tetromino_J_2 = [[0, 3, 0],
[0, 3, 0],
[3, 3, 0]]
tetromino_J_3 = [[3, 0, 0],
[3, 3, 3],
[0, 0, 0]]
tetromino_J_4 = [[0, 3, 3],
[0, 3, 0],
[0, 3, 0]]
tetromino_S_1 = [[0, 0, 0],
[0, 4, 4],
[4, 4, 0]]
tetromino_S_2 = [[4, 0, 0],
[4, 4, 0],
[0, 4, 0]]
tetromino_Z_1 = [[0, 0, 0],
[5, 5, 0],
[0, 5, 5]]
tetromino_Z_2 = [[0, 5, 0],
[5, 5, 0],
[5, 0, 0]]
tetromino_T_1 = [[0, 0, 0],
[6, 6, 6],
[0, 6, 0]]
tetromino_T_2 = [[0, 6, 0],
[6, 6, 0],
[0, 6, 0]]
tetromino_T_3 = [[0, 6, 0],
[6, 6, 6],
[0, 0, 0]]
tetromino_T_4 = [[0, 6, 0],
[0, 6, 6],
[0, 6, 0]]
tetromino_O = [[7, 7],
[7, 7]]
tetromino_I = [tetromino_I_1, tetromino_I_2]
tetromino_L = [tetromino_L_1, tetromino_L_2, tetromino_L_3, tetromino_L_4]
tetromino_J = [tetromino_J_1, tetromino_J_2, tetromino_J_3, tetromino_J_4]
tetromino_S = [tetromino_S_1, tetromino_S_2]
tetromino_Z = [tetromino_Z_1, tetromino_Z_2]
tetromino_T = [tetromino_T_1, tetromino_T_2, tetromino_T_3, tetromino_T_4]
tetromino_O = [tetromino_O]
tetrominos = [tetromino_I, tetromino_L, tetromino_J, tetromino_S,
tetromino_Z, tetromino_T, tetromino_O]
class Tetromino:
def __init__(self, map_cols: int):
self.tetromino_type = random.randint(0, len(tetrominos) - 1)
self.type_variants = len(tetrominos[self.tetromino_type])
self.orient = 0
self.length = len(tetrominos[self.tetromino_type][0])
self.pos_x = random.randint(1, map_cols - self.length - 1)
self.pos_y = 1