import pygame
import random
import math
WIDTH = 500
HEIGHT = 500
pygame.init()
screen = pygame.display.set_mode((WIDTH, HEIGHT))
running = True
size1 = 50
size2 = 50
state= 0
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_RETURN:
pygame.image.save(screen, "image.jpg")
if state < 100:
pygame.draw.rect(screen,(255, 255, 255), ((WIDTH - size1)/2, (HEIGHT- size2)/2, size1,size2),2)
pygame.draw.rect(screen,(255, 255, 255), ((WIDTH - size1)/2, (HEIGHT- size2)/2, size1,size2),2)
size1 += random.randint(25,50)
size2 += random.randint(25,50)
x = (WIDTH - size1)/2
y=(HEIGHT- size2)/2
pygame.draw.circle(screen,(255,0,0), (x, y), 5)
pygame.draw.circle(screen,(255,0,0), (500-x, y), 5)
pygame.draw.circle(screen,(255,0,0), (500-x,500- y), 5)
pygame.draw.circle(screen,(255,0,0), (x,500- y), 5)
pygame.display.flip()
state += 1
pygame.quit()
|