0

I'm trying to send "waves" of enemies with this code:

        wavechooser = random.randint(1, 4)
        print wavechooser
        if wavechooser == 1:
            wave1()

But when I run this, the enemies that I send using wave1() keep flickering. My wave1() code runs fine wihtout the wavechooser, but with the wavechooser comes the problem.

I'm guessing this is because wavechooser is in a while statement, so the values of wavechooser keep changing.

So my question is, how would I keep the enemy opaque? I would prefer to not change the if statement because I want to send multiple waves at once.

wave1() code:

def wave1():
global timer
global timer1
global angle
speed = random.uniform(0.1, 0.9)
index = 0

# removing enemies
for enemy1 in enemies:
    if enemy1[0] < 330:
        enemy.pop(index)
    enemy1[0] -= speed
    index += 1
for enemy1 in enemies:
    screen.blit(enemy, enemy1)

As I said, this part seems to be working fine individually.

EDIT: Also, after I send a wave, I can't seem to be able to send another one. Do I need to post more code? EDIT: Some of the outputted values of wavechooser

3
4
3
4
3
2
4
1
3
3
3
4
3
1
2
4
3
1
2
4
1
3
2
3
2
3
4
2
2
1
1
4
3
2
4
2
4
2
3
tabibito
  • 674
  • 9
  • 24
  • As your code has nothing to do with the actual blitting to the screen we can't help you. – Fredrik Feb 07 '16 at 21:47
  • Okay, I'll add the wave1 method; I didn't want to do so because I'm trying to keep my program secret :P I'll rename the variables. – tabibito Feb 08 '16 at 00:14
  • 1
    to send more wave you should keep all waves on list - `all_waves.append( enemies)`. As for me function `wave1()` should only create wave. Different function (without `if wavechooser`) should draw/blit all enemies from all waves – furas Feb 08 '16 at 03:20

0 Answers0