-
Notifications
You must be signed in to change notification settings - Fork 0
/
tetris.py
executable file
·62 lines (48 loc) · 1.21 KB
/
tetris.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
from apcs import *
import random
map = []
scale = 20
size = [10,24]
Window.size(size[0]*scale, size[1]*scale)
for i in range(size[1]):
map.append(["grey"]*size[0])
ch = 0
cv = 0
def main():
global map, ch, cv
Window.out.background("black")
s = scale/2
def block(x,y, color, border="black"):
Window.out.color(border)
Window.out.square(x,y,scale)
Window.out.color(color)
Window.out.square(x,y,scale-4)
def lell(x, y):
lcolor = "orange"
map[y][x] = lcolor
map[y+1][x] = lcolor
map[y+1][x-1] = lcolor
map[y-1][x] = lcolor
def rell(h, v):
lcolor = "orange"
map[v][h] = lcolor
map[v-1][h] = lcolor
map[v][h-1] = lcolor
map[v][h-2] = lcolor
def ooo(x, y):
lcolor = "yellow"
map[v][h] = lcolor
map[v-1][h] = lcolor
map[v][h-1] = lcolor
map[v][h-2] = lcolor
#cpiece = random.choice([rell, lell, ooo, line, zzz, ttt])
rowc = 0
for line in map:
colc = 0
for color in line:
block(colc*scale+s, rowc*scale+s, color)
colc += 1
rowc += 1
lell(5,3)
Window.frame(main)
Window.start()