mercredi 11 août 2021

Why the if statement is being executed yet the condition is false?

Even if the variable bullets_fire contains the boolean False, the command below is going to be executed. I also added print statement for bullets_fire nested in if statement, and it outputs False, why it's being executed then?

if event.type == pygame.KEYDOWN:
    if event.key == pygame.K_SPACE and not bullets_fire:
        print(bullets_fire)
        bullets_fire = True
        bullets_x = player_x
        bullets_y = player_y

Aucun commentaire:

Enregistrer un commentaire