-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconstants.py
111 lines (88 loc) · 2.31 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
import os
from kivy.core.image import Image
# Size of each block in the game.
BLOCK_SIZE = 40
# Origin of the board coordinates.
ORIGIN_X = 8 * BLOCK_SIZE
ORIGIN_Y = BLOCK_SIZE
# Size of the game board
HEIGHT = 20
WIDTH = 10
# Size of the window;
WINDOW_WIDTH = (WIDTH + 9) * BLOCK_SIZE
WINDOW_HEIGHT = (HEIGHT + 2) * BLOCK_SIZE
# Get the file names of textures
files = os.listdir('textures')
# Create TEXTURES dict
TEXTURES = {}
# Add every texture to TEXTURES
for file in files:
name = file[:file.index('.')]
path = 'textures/' + file
TEXTURES[name] = Image.load(path).texture
del os, Image
# Pieces organizations and textues definitions.
PIECES = [
# PIECE I
{
'rotations': [
[(-2, 0), (-1, 0), (0, 0), (1, 0)],
[(0, 0), (0, 1), (0, 2), (0, 3)]
],
'texture': TEXTURES['cyan_block']
},
# PIECE S
{
'rotations': [
[(-1, 0), (0, 0), (0, 1), (1, 1)],
[(0, 0), (0, 1), (-1, 1), (-1, 2)]
],
'texture': TEXTURES['green_block']
},
# PIECE Z
{
'rotations': [
[(-1, 1), (0, 1), (0, 0), (1, 0)],
[(-1, 0), (-1, 1), (0, 1), (0, 2)]
],
'texture': TEXTURES['red_block']
},
# PIECE L
{
'rotations': [
[(-1, 2), (-1, 1), (-1, 0), (0, 0)],
[(-1, 0), (-1, 1), (0, 1), (1, 1)],
[(0, 0), (0, 1), (0, 2), (-1, 2)],
[(-1, 0), (0, 0), (1, 0), (1, 1)]
],
'texture': TEXTURES['orange_block']
},
# PIECE J
{
'rotations': [
[(-1, 0), (0, 0), (0, 1), (0, 2)],
[(-1, 1), (-1, 0), (0, 0), (1, 0)],
[(-1, 0), (-1, 1), (-1, 2), (0, 2)],
[(-1, 1), (0, 1), (1, 1), (1, 0)]
],
'texture': TEXTURES['blue_block']
},
# PIECE O
{
'rotations': [
[(-1, 0), (0, 0), (-1, 1), (0, 1)]
],
'texture': TEXTURES['yellow_block']
},
# PIECE T
{
'rotations': [
[(-1, 0), (0, 0), (1, 0), (0, 1)],
[(-1, 0), (-1, 1), (-1, 2), (0, 1)],
[(-1, 1), (0, 1), (1, 1), (0, 0)],
[(-1, 1), (0, 0), (0, 1), (0, 2)]
],
'texture': TEXTURES['purple_block']
}
]
SCORE_PER_LINE = {1: 40, 2: 100, 3: 300, 4: 1200}