-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCircle
More file actions
65 lines (55 loc) · 1.74 KB
/
Copy pathCircle
File metadata and controls
65 lines (55 loc) · 1.74 KB
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
import pygame
pygame.init()
FPS = 15
SCREEN_SIZE = WIN_WIDTH, WIN_HEIGHT = 400, 400
gray = (170,170,170)
yellow = (230, 200, 20)
White = (255,255,255)
rect_width = WIN_WIDTH // 2
rect_height = WIN_HEIGHT // 2
rect_size = (rect_width, rect_height)
BACK_COLOR = White
CIRCLE_COLOR = yellow
clock = pygame.time.Clock()
sc = pygame.display.set_mode(SCREEN_SIZE)
sc.fill(BACK_COLOR)
rect_1 = pygame.Rect((0, 0), rect_size)
rect_2 = pygame.Rect((rect_width, 0), rect_size)
rect_3 = pygame.Rect((rect_width, rect_height), rect_size)
rect_4 = pygame.Rect((0, rect_height), rect_size)
surf_1 = pygame.Surface(rect_size)
surf_2 = pygame.Surface(rect_size)
surf_3 = pygame.Surface(rect_size)
surf_4 = pygame.Surface(rect_size)
surf_1.fill(BACK_COLOR)
surf_2.fill(BACK_COLOR)
surf_3.fill(BACK_COLOR)
surf_4.fill(BACK_COLOR)
sc.blit(surf_1, rect_1)
sc.blit(surf_2, rect_2)
sc.blit(surf_3, rect_3)
sc.blit(surf_4, rect_4)
circle_update = (rect_1, rect_2, rect_3, rect_4)
while 1:
for i in pygame.event.get():
if i.type == pygame.QUIT:
pygame.quit()
exit()
if i.type == pygame.KEYDOWN:
if i.key == pygame.K_ESCAPE:
pygame.quit()
exit()
if i.key == pygame.K_1:
circle_update = (rect_1, rect_3)
elif i.key == pygame.K_2:
circle_update = (rect_2, rect_4)
elif i.key == pygame.K_0:
circle_update = (rect_1, rect_2, rect_3, rect_4)
if CIRCLE_COLOR == yellow:
CIRCLE_COLOR = gray
elif CIRCLE_COLOR == gray:
CIRCLE_COLOR = yellow
pygame.draw.circle(sc, CIRCLE_COLOR, (WIN_WIDTH // 2, WIN_HEIGHT // 2), 100)
pygame.display.update(circle_update)
pygame.time.delay(500)
clock.tick(FPS)