mardi 31 mars 2020

I am getting an invalid syntax error when using elif statement (Not an indentation error)

Should be an easy issue to solve. If you see my code below, the line that reads 'elif target_2.got_away == True:' is returning an invalid syntax error. I have read other posts on this an all tips regard either not using an 'IF' statement before the elif or wrong indentation, which I believe this to be neither.

def refresh_window():
  if len(target_sprites) > 0:
   window.blit(bgr, (0,0))
  if len(target_sprites) == 0:
    window.blit(winner, (0,0))
  if target_1.got_away == True:
    window.blit(loser, (0,0)
  elif target_2.got_away == True:
    window.blit(loser, (0,0))
  elif target_3.got_away == True:
    window.blit(loser, (0,0))
  elif target_4.got_away == True:
    window.blit(loser, (0,0))
  elif target_5.got_away == True:
    window.blit(loser, (0,0))
  elif target_6.got_away == True:
    window.blit(loser, (0,0))
  player_sprites.draw(window)
  target_sprites.draw(window)
  for item in all_bullets:
    pygame.draw.rect(window, BLUE, (item['x']-5, item['y']-5, 10, 10))
    b_hitbox = (item['x']-10, item['y']-10, 20, 20)
    pygame.draw.rect(window, BLUE, b_hitbox, 2)
  pygame.display.update()

Aucun commentaire:

Enregistrer un commentaire