import pygame
import random
pygame.init()
win = pygame.display.set_mode((500,500))
pygame.display.set_caption("")
pygame.time.set_timer(pygame.USEREVENT, 100)
run = True
while run:
pygame.time.delay(100)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_RETURN:
pygame.image.save(win, "image.jpg")
if event.type == pygame.USEREVENT:
r = random.randint(0,255)
g = random.randint(0,255)
b = random.randint(0,255)
pos = (random.randint(0,500),random.randint(0,500))
pygame.draw.circle(win, (r,g,b), pos, 20)
pygame.display.update()
pygame.quit()
|