import pygame
pygame.init()
screen = pygame.display.set_mode((500, 500))
running = True
x = 50
y = 50
clock = pygame.time.Clock()
while running:
clock.tick(60)
screen.fill((0, 255, 0))
pygame.draw.rect(screen, (255,0,0), (x, y, 30, 30))
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_d:
x += 5
if event.key == pygame.K_a:
x -= 5
if event.key == pygame.K_s:`enter code here`
y += 5
if event.key == pygame.K_w:
y -= 5
pygame.display.update()
Trying to move my second sprite with the w, a, s, d, keys, however it does not seem to be working. When I change pygame.K_d to pygame.K_RIGHT, it works well just as normal. Wondering if I've made a mistake in my code or it is an error with my keyboard. Thanks a lot.