Reputation: 89
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
Upvotes: 0
Views: 1061
Reputation: 1995
your condition contains not
before the boolean variable.
it will execute only if event.key == pygame.K_SPACE
evaluates as True
and bullets_fire
evaluated as False
, since not False
is the same as True
.
Upvotes: 1