import pygame

# Homework: make a ball bounce off all four walls.
# The ball has an x and y position, and an x and y velocity (speed_x, speed_y).
# Each frame, add the velocity to the position.
# When the ball hits a wall, reverse the matching velocity component:
#   - left/right walls: speed_x = -speed_x
#   - top/bottom walls: speed_y = -speed_y
# The ball has a radius of 20.

pygame.init()

screen = pygame.display.set_mode((640, 480))
pygame.display.set_caption("Bouncing Ball")
clock = pygame.time.Clock()

BG     = (15, 15, 30)
YELLOW = (240, 200, 40)

RADIUS = 20
x = 320
y = 240
# TODO: define speed_x and speed_y (try 3 and 2 to start)
speed_x = 3
speed_y = 2

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

    # TODO: update x and y by adding speed_x and speed_y
    # TODO: check each wall and reverse the correct speed component

    screen.fill(BG)
    pygame.draw.circle(screen, YELLOW, (int(x), int(y)), RADIUS)
    pygame.display.flip()
    clock.tick(60)

pygame.quit()
