import pygame
import random
pygame.init()
win = pygame.display.set_mode((500,500))
pygame.display.set_caption("")
circleX = 250
circleY = 0
xSpeed = 10
ySpeed = 10
r = 20
run = True
while run:
pygame.time.delay(100)
win.fill((0,0,0))
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
if(circleX < 0 or circleX > 450):
xSpeed = xSpeed * -1;
r = r + 5
if (circleY < 0 or circleY > 450):
r = r + 5
ySpeed = ySpeed * -1
pos = (circleX,circleY)
circleX = circleX + xSpeed;
circleY = circleY + ySpeed;
pygame.draw.circle(win, (255,255,255), pos, r)
pygame.display.update()
pygame.quit()
|