import pygame
import random
WIDTH = 500
HEIGHT = 700
FPS = 60
WHITE = (255, 255, 255)
pygame.init()
screen = pygame.display.set_mode((WIDTH, HEIGHT))
f1 = pygame.font.Font(None, 36)
running = True
screen.fill((0, 0, 0))
for it_1 in range(0,500,50):
for it_2 in range(0,500,50):
pygame.draw.rect(screen,WHITE, (it_1,it_2,49,49))
x = 0
y = 0
random_color = (255, 255, 255)
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if event.type == pygame.MOUSEBUTTONDOWN:
if event.button == 1:
pos = pygame.mouse.get_pos()
x = pos[0]
y = pos[1]
x = x //50*50
y = y //50*50
random_color =(random.randint(0,255),random.randint(0,255),random.randint(0,255))
pygame.draw.rect(screen,random_color, (x,y,49,49))
pygame.display.update()
pygame.time.delay(250)
pygame.quit()
|