|
import pygame
import sys
WIDTH=640
HEIGHT=480
x = 163
y = 120
dx = 10
dy = 10
BLACK = (0,0,0)
WHITE = (255,255,255)
pygame.init()
screen = pygame.display.set_mode((WIDTH,HEIGHT))
clock = pygame.time.Clock()
while True:
clock.tick(10)
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
x += dx
y += dy
if x < 0 or x > WIDTH:
dx = -dx
if y < 0 or y > HEIGHT:
dy = -dy
screen.fill(BLACK)
pygame.draw.circle(screen, WHITE, (x,y), 8)
pygame.display.flip()
|
|