import pygame, sys
from pygame.locals import *

pygame.init()
DISPLAYSURF = pygame.display.set_mode((1000, 600))
pygame.display.set_caption("Testing!")

black = pygame.Color(0,0,0)
red = pygame.Color(255,0,0)
clock = pygame.time.Clock()

x = 10
y = 10
r = 10
dx = 2
dy = 2

while True:

    # How to clear the canvas!!!
    
    for event in pygame.event.get():

        # Learn other types of events that can happen
        
        if event.type == QUIT:
            pygame.quit()
            sys.exit()    

    # Learn how to do tick here...
    x += dx
    y += dy

    if x >= 1000-2*r or x <= 0:
        x -= dx
        dx = -dx
    if y >= 600-2*r or y <= 0:
        y -= dy
        dy = -dy

    DISPLAYSURF.fill(black)
    pygame.draw.ellipse(DISPLAYSURF, red, (x, y, 2*r, 2*r), 0)

    pygame.display.update()
    #clock.tick(30)
