I have a checkboard game set up with two gun sprites. I want to be able to move the gun sprites around freely but for some reason, pygame keeps missing my inputs. The code I have set up for the gun sprites is
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
screen.blit(background, (0, 0))
if gunrotationcheck == 0: #Checks if gunrotationcheck is set to 0. If true, replace gun with up sprite
gun = pygame.image.load('gun_up.png')
screen.blit(gun, (gunx,guny))
elif gunrotationcheck == 1: #Checks if gunrotationcheck is set to 1. If true, replace gun with left sprite
gun = pygame.image.load('gun_left.png')
screen.blit(gun, (gunx-25,guny+30)) #Position fix
elif gunrotationcheck == 3: #Checks if gunrotationcheck is set to 3. If true, replace gun with down sprite
gun = pygame.image.load('gun_down.png')
screen.blit(gun, (gunx,guny))
elif gunrotationcheck == 2: #Checks if gunrotationcheck is set to 2. If true, replace gun with right sprite
gun = pygame.image.load('gun_right.png')
screen.blit(gun, (gunx-25,guny+30)) #Position fix
events = pygame.event.get()
for event in events:
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_a: #Move left
gunx -= 50
if event.key == pygame.K_d: #Move right
gunx += 50
if event.key == pygame.K_w: #Move up
guny -= 50
if event.key == pygame.K_s: #Move down
guny += 50
if event.key == pygame.K_j: #Turn left
gunrotationcheck = 1
gun = pygame.image.load('gun_left.png')
screen.blit(gun, (gunx,guny))
if event.key == pygame.K_l: #Turn right
gunrotationcheck = 2
gun = pygame.image.load('gun_right.png')
screen.blit(gun, (gunx,guny))
if event.key == pygame.K_i: #Turn up
gunrotationcheck = 0
gun = pygame.image.load('gun_up.png')
screen.blit(gun, (gunx,guny))
if event.key == pygame.K_k: #Turn down
gunrotationcheck = 3
gun = pygame.image.load('gun_down.png')
screen.blit(gun, (gunx,guny))```