I am making a shooting game in pygame, but this code:
checkfocus = pygame.key.get_focused()
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if event.type == pygame.KEYDOWN:
#THIS PART DOES NOT WORK
if event.type == pygame.K_w:
print(checkfocus)
print("up")
pygame.key.set_repeat(0, 1)
yvalue -= 20
if yvalue < 0:
yvalue = 0
print(yvalue)
pygame.time.wait(100)
screen.fill((52, 61, 82))
screen.blit(harryshoot, (20, yvalue))
pygame.display.flip()
somehow doesn't work, despite other if event.type
codes working just fine. Whats the problem here? Why is it only this code that does not get keyboard input? I have tried changing the keys, but that didn't help.(print("up")
also does not show up so it's not the code itself which is not working).