lundi 15 juin 2020

How do I check for a certain condition and implement it once with reference to pygame

I'm making a pygame game and I want to increase the number of enemies whenever the player reaches 20 kills i.e kills % 20 == 0. I have a function enemy_spawn(number_of_enemies) and I implemented the following code below. I would like to know what I'm doing wrong because there are infinite enemies once it executes. Please suggest some possible fixes. I have attached only the relevant code. Thank you.

number_of_enemies = 5
num_check = False

redrawWindow():
    global num_check
    global number_of_enemies

    if kills%20 == 0 and kills > 1:
        num_check = True
    if num_check:
        number_of_enemies += 1
        num_check = False

Aucun commentaire:

Enregistrer un commentaire