CCCPaste

4520d04911c66

import pygame

pygame.init()
screen = pygame.display.set_mode((800, 600))
clock = pygame.time.Clock()
running = True
x=20
yon='sag'

while running:

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    screen.fill("white")

    if yon=='sag':
        if x <= 780:
            x += 1
        else:
            yon='sol'

    elif yon == 'sol':
        x -= 1

    pygame.draw.circle(screen, "red", (x,300), 20) 

    pygame.display.flip()

    clock.tick(60)

pygame.quit()