-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconstants.py
164 lines (149 loc) · 2.77 KB
/
constants.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import random
# Display dimensions in px
SCREEN_WIDTH = 700
SCREEN_HEIGHT = 600
GRID_WIDTH = 250
GRID_HEIGHT = 500
TOP_LEFT = [(SCREEN_WIDTH - GRID_WIDTH) // 2, SCREEN_HEIGHT - GRID_HEIGHT-20]
BLOCK_SIZE = 25
S = [['.....',
'......',
'..**..',
'.**...',
'.....'],
['.....',
'..*..',
'..**.',
'...*.',
'.....'],
['.....',
'......',
'..**..',
'.**...',
'.....'],
['.....',
'..*..',
'..**.',
'...*.',
'.....']]
Z = [['.....',
'.**..',
'..**.',
'.....',
'.....'],
['...*.',
'..**.',
'..*..',
'.....'
'.....'],
['.....',
'.**..',
'..**.',
'.....',
'.....'],
['...*.',
'..**.',
'..*..',
'.....'
'.....']]
I = [['..*..',
'..*..',
'..*..',
'..*..',
'.....'],
['.....',
'.....',
'****.',
'.....',
'.....'],
['.....',
'..*..',
'..*..',
'..*..',
'..*..'],
['.....',
'.....',
'.****',
'.....',
'.....']]
O = [['.....',
'.....',
'.**..',
'.**..',
'.....']]
J = [['.....',
'.*...',
'.***.',
'.....',
'.....'],
['..**.',
'..*..',
'..*..',
'.....'
'.....'],
['.....',
'.***.',
'...*.',
'.....',
'.....'],
['..*..',
'..*..',
'.**..',
'.....',
'.....']]
L = [['.....',
'...*.',
'.***.',
'.....',
'.....'],
['..*..',
'..*..',
'..**.',
'.....',
'.....'],
['.....',
'.***.',
'.*...',
'.....',
'.....'],
['.**..',
'..*..',
'..*..',
'.....',
'.....']]
T = [['.....',
'..*..',
'.***.',
'.....',
'.....'],
['..*..',
'..**.',
'..*..',
'.....',
'.....'],
['.....',
'.***.',
'..*..',
'.....',
'.....'],
['..*..',
'.**..',
'..*..',
'.....',
'.....']]
shapes = {"S" : S, "Z": Z, "I" : I, "O" : O, "J" : J, "L" : L, "T" :T}
shape_colors = {"I" : (66,247,247), "S" : (228,14,9), "Z" : (13,233,0), "T" : (157,0,230), "L" :(232,155,3), "J": (0,4,225), "O" : (247,247,66)}
class Game_piece:
"""Class for the active Tetrimino object, holds states, color, and position of each tetrimino"""
def __init__(self):
self.block = random.choice(list(shapes.keys()))
# Shape Name, single character
self.shape = shapes[self.block]
# Rotation state, depends on shape
self.r_state = 0
self.num_r_state = len(self.shape)
# RGB Value (Red, Green, Blue)
self.color = shape_colors[self.block]
# Position
self.x = 5
self.y = 0