import pygame
import sys
import random
pygame.font.init()
sc = pygame.display.set_mode((500, 500))
x = random.randint(50,450)
y = random.randint(50,450)
flag = 0
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
if event.type == pygame.MOUSEBUTTONDOWN:
if event.button == 1:
if flag == 0:
flag = 1
else:
flag = 0
sc.fill((0, 0, 0))
pygame.draw.rect(sc, (255, 255, 255), (x,y, 49, 49))
if flag == 1:
pygame.draw.rect(sc, (64, 128, 255),
(x, y, 49,49), 8)
pygame.display.update()
|