import pygame
import random
WIDTH = 500
HEIGHT = 700
FPS = 60
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
pygame.init()
screen = pygame.display.set_mode((WIDTH, HEIGHT))
f1 = pygame.font.Font(None, 36)
running = True
x = 0
y = 0
state = 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:
pos = pygame.mouse.get_pos()
x = pos[0]
y = pos[1]
x = x //50*50
y = y //50*50
state = 1
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))
if (state == 1):
pygame.draw.rect(screen,GREEN, (x,y,49,49))
for i in range(0,10):
newx = x + random.randint(0,5)*50
newy = y + random.randint(0,5)*50
pygame.draw.rect(screen,GREEN, (newx,newy,49,49))
pygame.display.update()
pygame.time.delay(250)
pygame.quit()
|