fixed neverending loop
This commit is contained in:
parent
7cf6638cb9
commit
d91f82a889
1 changed files with 3 additions and 0 deletions
|
@ -49,8 +49,10 @@ def generate_targets(player, window_size, Levels):
|
||||||
firebacks = len(sprite_list)
|
firebacks = len(sprite_list)
|
||||||
else: firebacks = level.firebacks
|
else: firebacks = level.firebacks
|
||||||
for i in range(firebacks):
|
for i in range(firebacks):
|
||||||
|
loop = 0
|
||||||
changed = False
|
changed = False
|
||||||
while not changed:
|
while not changed:
|
||||||
|
if loop == firebacks: changed = True
|
||||||
index = randint(0, len(sprite_list)-1) if (len(sprite_list) - 1 != 0) else 0
|
index = randint(0, len(sprite_list)-1) if (len(sprite_list) - 1 != 0) else 0
|
||||||
if sprite_list[index].type != "SHOOTER":
|
if sprite_list[index].type != "SHOOTER":
|
||||||
sprite_list[index].type = "SHOOTER"
|
sprite_list[index].type = "SHOOTER"
|
||||||
|
@ -60,6 +62,7 @@ def generate_targets(player, window_size, Levels):
|
||||||
sprite_list[index].rect = sprite_list[index].image.get_rect()
|
sprite_list[index].rect = sprite_list[index].image.get_rect()
|
||||||
sprite_list[index].set_position(x,y, center=False) #Already Centered!
|
sprite_list[index].set_position(x,y, center=False) #Already Centered!
|
||||||
changed = True
|
changed = True
|
||||||
|
loop += 1
|
||||||
|
|
||||||
if len(sprite_list) < level.powerups:
|
if len(sprite_list) < level.powerups:
|
||||||
powerups = len(sprite_list)
|
powerups = len(sprite_list)
|
||||||
|
|
Reference in a new issue