import pygame
import random
RED = (250, 0, 0)
GREEN = (0, 250, 0)
BLUE = (0, 0, 250)
pygame.font.init()
pygame.init()
screen = pygame.display.set_mode((400, 300))
screen.fill((255,255,255))
f1 = pygame.font.SysFont('serif', 48)
select = 0
color_1 = 0
color_2 = 0
color_3 = 0
color_4 = 0
process = 0
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
if (event.type == pygame.KEYDOWN):
screen.fill((255,255,255))
if (event.key == pygame.K_1):
process = 0
if (color_1 == color_2):
text1 = f1.render("цвет совпал", False,(0, 180, 0))
screen.blit(text1, (10, 100))
else:
text1 = f1.render("цвет не совпал", False,(0, 180, 0))
screen.blit(text1, (10, 100))
if (event.key == pygame.K_2):
process = 0
if (color_1 == color_3):
text1 = f1.render("цвет совпал", False,(0, 180, 0))
screen.blit(text1, (10, 100))
else:
text1 = f1.render("цвет не совпал", False,(0, 180, 0))
screen.blit(text1, (10, 100))
if (event.key == pygame.K_3):
process = 0
if (color_1 == color_4):
text1 = f1.render("цвет совпал", False,(0, 180, 0))
screen.blit(text1, (10, 100))
else:
text1 = f1.render("цвет не совпал", False,(0, 180, 0))
screen.blit(text1, (10, 100))
if (process == 0):
process = 1
color = random.randint(0,2)
if (color == 0):
color_2 = RED
color_3 = GREEN
color_4 = BLUE
if (color == 1):
color_2 = BLUE
color_3 = GREEN
color_4 = RED
if (color == 2):
color_2 = GREEN
color_3 = BLUE
color_4 = RED
color = random.randint(0,2)
if (color == 0):
color_1 = RED
if (color == 1):
color_1 = BLUE
if (color == 2):
color_1 = GREEN
pygame.draw.rect(screen, color_1, pygame.Rect(0,0, 50, 50))
pygame.draw.rect(screen, color_2, pygame.Rect(0,60, 50, 50))
pygame.draw.rect(screen, color_3, pygame.Rect(60,60,50,50))
pygame.draw.rect(screen, color_4, pygame.Rect(120,60,50,50))
pygame.display.flip()
|