-
Notifications
You must be signed in to change notification settings - Fork 0
/
quadrados_fullscreen.py
43 lines (36 loc) · 1.1 KB
/
quadrados_fullscreen.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
# primeiro programa que eu aprendi com o João Bueno fera
# pygame.org/docs/
import pygame
import random
W, H = 800, 600
tela = pygame.display.set_mode((W, H), pygame.FULLSCREEN)
def sorteia():
r = random.randrange(0, 256, 127)
g = random.randrange(0, 256, 127)
b = random.randrange(0, 256, 127)
return (r, g, b)
def desenha(tamanho):
for y in range(0, H, tamanho):
for x in range(0, W, tamanho):
pygame.draw.rect (tela, sorteia(), (x, y, tamanho, tamanho))
def principal():
tamanho = 100
while True:
eventos = pygame.event.get()
for evento in eventos:
if evento.type == pygame.QUIT:
return
if evento.type == pygame.KEYDOWN:
if evento.key == pygame.K_ESCAPE:
return
if evento.key == pygame.K_LEFT:
tamanho = tamanho - 10
if evento.key == pygame.K_RIGHT:
tamanho = tamanho + 10
desenha(tamanho)
pygame.display.flip()
pygame.time.delay(100)
try:
principal()
finally:
pygame.quit()