import pygame
import random
WIDTH = 500
HEIGHT = 500
FPS = 60
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
colors = []
colors.append(WHITE)
colors.append(BLACK)
colors.append(RED)
colors.append(GREEN)
colors.append(BLUE)
pygame.init()
screen = pygame.display.set_mode((WIDTH, HEIGHT))
f1 = pygame.font.Font(None, 36)
running = True
counter = 0
numbers = []
state_program = 0
cnt = 0
for index in range(0,25,1):
numbers.append(0)
while running:
screen.fill(BLACK)
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if event.type == pygame.MOUSEBUTTONDOWN:
if event.button == 1:
x, y = pygame.mouse.get_pos()
ipos = 0
if y//100 == 0:
ipos = 5*(x//100)
if y//100 == 1:
ipos = 5*(x//100)+1
if y//100 == 2:
ipos = 5*(x//100)+2
if y//100 == 3:
ipos = 5*(x//100)+3
if y//100 == 4:
ipos = 5*(x//100)+4
numbers[ipos] += 1
if numbers[ipos] == 3 : cnt = cnt+1
if cnt == 25:
state_program = 1
print(cnt)
if (state_program == 0):
counter = 0
for it_1 in range(0,500,100):
for it_2 in range(0,500,100):
if (numbers[counter] > 4): numbers[counter] = 0;
pygame.draw.rect(screen,colors[numbers[counter]], (it_1,it_2,99,99))
font = pygame.font.SysFont(None, 34)
img = font.render(str(numbers[counter]), True, BLACK)
screen.blit(img, (it_1,it_2))
counter = counter + 1
if (state_program == 1):
screen.fill(GREEN)
pygame.display.update()
pygame.quit()
|