import pygame
from sys import exit
x = 125
y = 125
width = 20
height = 20
vel = 10
win = pygame.display.set_mode((500, 500))
key_press = pygame.key.get_pressed()
pygame.init()
screen = pygame.display.set_mode((500,500))
clock = pygame.time.Clock()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
exit()
if key_press == [pygame.K_UP] and y>0:
y += vel
pygame.draw.rect(win, (255, 0, 0), (x, y, width, height))
pygame.display.update()
clock.tick(60)
Any reason why it's not working? I do not understand, it should just change the variable of the block when the up arrow is pressed yet, it stays still once the program is opened