# Ian Binstock
# 6/4/26
# continuous.py
# A look at continuous movement when holding down the arrow keys

import pygame, sys
from pygame.locals import *

clock = pygame.time.Clock()
pygame.init()
DISPLAYSURF = pygame.display.set_mode((600, 600)) # window dimensions
pygame.display.set_caption("~Smooth this time~") # window caption

black = pygame.Color(0, 0, 0)
purple = pygame.Color(255, 0, 255)

x = 300 # ball's x position
y = 300 # ball's y position
dx = 5 # x velocity
dy = 5 # y velocity

# Game Loop
while True:
    keys = pygame.key.get_pressed() # boolean list that allows for searching if a key is pressed down
    if keys[pygame.K_DOWN]: # when down arrow is held, ball will move down
        y += dy
    if keys[pygame.K_UP]: # when up arrow is held, ball will move up
        y -= dy
    if keys[pygame.K_LEFT]: # when left arrow is held, ball will move left
        x -= dx
    if keys[pygame.K_RIGHT]: # when right arrow is held, ball will move right
        x += dx

    for event in pygame.event.get():
        print(keys)

        if event.type == QUIT:
            pygame.quit()
            sys.exit()


    DISPLAYSURF.fill(black) # set background as black
    pygame.draw.circle(DISPLAYSURF, purple, (x, y), 20, 0) # draw ball
    pygame.display.update() # update frame

    clock.tick(50)

