I can only move the rectangle every time I push a key down. How would I continuously move my shape when the key is down?
Here's my code:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running=False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_d:
lead_x_change += -10
if event.key == pygame.K_a:
lead_x_change += 10
if event.key == pygame.K_w:
lead_y_change += -10
if event.key ==pygame.K_s:
lead_y_change += 10
if event.type == pygame.KEYUP:
if event.key == pygame.K_a or event.key == pygame.K_d:
lead_x_change = 0
rectx += lead_x_change
screen.fill(color)
rect=pygame.Rect(rectx,recty,10,10)
screen = pygame.display.set_mode(screen_dimensions)
pygame.display.update()