import pygame
import sys
import random
pygame.font.init()
sc = pygame.display.set_mode((500, 500))
x = 500
y = 500
old_x = 0
old_y = 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:
x = event.pos[0]
y = event.pos[1]
old_x = x
old_y = y
sc.fill((0, 0, 0))
pygame.draw.rect(sc, (255,0, 0), (old_x,old_y, 50, 50))
pygame.draw.rect(sc, (255, 255, 255), (x,y, 50, 50))
y = y + 1
if y == 500:
y = old_y
x = old_x
pygame.time.delay(5)
pygame.display.update()
|