import pygame as pg
import sys
import random
WHITE = (255, 255, 255)
BLUE = (0, 0, 225)
sc = pg.display.set_mode((500, 500))
sc.fill(WHITE)
pg.display.update()
pos_x = []
pos_y = []
counter = 1
pos_x.append(random.randint(100,400))
pos_y.append(random.randint(100,400))
while 1:
for i in pg.event.get():
if i.type == pg.QUIT:
sys.exit()
if i.type == pg.MOUSEBUTTONDOWN:
pos_x.append(random.randint(100,400))
pos_y.append(random.randint(100,400))
counter += 1
if (counter == 10): counter = 1
pressed = pg.mouse.get_pressed()
pos = pg.mouse.get_pos()
sc.fill(WHITE)
for t in range(counter):
pg.draw.rect(sc, BLUE, pg.Rect(pos_x[t],pos_y[t], 50, 50))
pg.display.flip()
|