#Trisha Ruiz
#6/14/2023
#continuous movment

#init
import pygame, sys
from pygame.locals import *
pygame.init()

#window settings
DISPLAYSURF = pygame.display.set_mode((300, 300))
clock = pygame.time.Clock()

#constants
VEL = 5

x = 150
y = 150

while True:
    clock.tick(60)
    
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()

    keys = pygame.key.get_pressed() #return state of all our keys
                                    #1 - pressed | 0 - not pressed

    #move character based on key press
    x = (x + (keys[pygame.K_RIGHT] - keys[pygame.K_LEFT]) * VEL) % 300 #mod helps wrap around
    y = (y + (keys[pygame.K_DOWN] - keys[pygame.K_UP]) * VEL) % 300

    #draw our frame
    DISPLAYSURF.fill(0)
    pygame.draw.rect(DISPLAYSURF, (255, 0, 0), (x, y, 20, 20))
    pygame.display.update()


