-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tetris.py
59 lines (46 loc) · 1.57 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
import TetraFactory
import TetraBucket
import pygame
#pygame initialization and configuration
pygame.init()
gameDisplay = pygame.display.set_mode((120,220))
pygame.display.set_caption('Tetrus')
#bg = pygame.image.load('1993-buick-lesabre-7.jpg')
white = (255,255,255)
black = (45,45,45)
#Tetra factory and Tetra Bucket initialization and configuration
factory = TetraFactory.Factory()
bucket = TetraBucket.Bucket(factory, gameDisplay)
gameExit = False
#main game timer
pygame.time.set_timer(pygame.USEREVENT+1, 300)
while not gameExit:
#left, right, middle
#pygame.draw.rect(gameDisplay, white, [0,0,10,220])
#pygame.draw.rect(gameDisplay, white, [110,0,10,220])
#pygame.draw.rect(gameDisplay, white, [0,210,110,10])
bucket.update()
pygame.display.update()
for event in pygame.event.get():
if event.type == pygame.USEREVENT+1:
bucket.move('down')
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_DOWN:
bucket.move("down")
if event.key == pygame.K_UP:
bucket.move("up")
if event.key == pygame.K_LEFT:
bucket.move("left")
if event.key == pygame.K_RIGHT:
bucket.move("right")
if event.key == pygame.K_f:
bucket.rotate()
if event.key == pygame.K_i:
print(bucket.getCoords())
if event.key == pygame.K_c:
bucket.update()
bucket.cement()
if event.type == pygame.QUIT:
gameExit = True
pygame.quit()
quit()