import pygame
import random
pygame.init()
screen = pygame.display.set_mode([600, 400])
clock = pygame.time.Clock()
FPS = 500
radius = 50
running = True
x = 300
y = 200
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT]:
x -= 1
radius = random.randint(30,50)
if keys[pygame.K_RIGHT]:
x += 1
radius = random.randint(30,50)
if keys[pygame.K_UP]:
y -= 1
radius = random.randint(30,50)
if keys[pygame.K_DOWN]:
y += 1
radius = random.randint(30,50)
if (x < 0): x = 600
if (x > 600): x = 0
if (y < 0): y = 400
if (y > 400): y = 0
screen.fill((255,255,255))
pygame.draw.circle(screen, (0, 0, 0), (x,y), radius)
pygame.display.update()
clock.tick(FPS)
pygame.quit()
|