# Arup Guha
# 3/18/2020
# Showing a bouncing ball with pyGame

import pygame, sys
from pygame.locals import *

# Initial drawing stuff that I need for pygame.
pygame.init()
DISPLAYSURF = pygame.display.set_mode((1000, 600))
pygame.display.set_caption("Drawing!")

# Colors I will use.
black = pygame.Color(0,0,0)
green = pygame.Color(0,255,0)

# Variables that will specify where my bouncing ball is.
x = 0
y = 0
dx = 2
dy = 3
diameter = 30

# Main game loop.
while True:

    # Right now the only event we look for is quitting (x at top right)
    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()
            sys.exit()

    # Draw the black background and the ball.
    DISPLAYSURF.fill(black)
    pygame.draw.ellipse(DISPLAYSURF, green, (x, y, diameter, diameter), 0)

    # Update the screen's display and wait.
    pygame.display.update()
    pygame.time.delay(30)

    # Move the ball for the next frame.
    x = x + dx
    y = y + dy

    # Bounce off the left or right.
    if x > 1000-diameter or x < 0:
        dx = -dx

    # Bounce of the top or bottom
    if y > 600-diameter or y < 0:
        dy = -dy
