I am trying to start adding enemy types to my game, so I thought I would start with a fast enemy. I tried to make the fast enemies have a higher speed than the normal ones,. but it ended up making both of them faster.
this is the code i used:
for enemy in enemies:
enemy.move_in_direction(3)
enemy.animate()
if roll > 950:
bullet = Actor('enemy_bullet')
bullet.x = enemy.x
bullet.y = enemy.y
bullet.angle = random.randint(0, 359)
enemy_bullets.append(bullet)
if enemy.y > HEIGHT or game_state == "game_over":
enemies.remove(enemy)
for fastenemy in enemies:
fastenemy.move_in_direction(6)
if fastenemy.y > HEIGHT or game_state == 'game_over':
enemies.remove(fastenemy)
if you need it, I can show the code I used for the enemy generation too.
2
The problem is that you are iterating over the exact same enemy array and moving the exact same enemies. Try adding some sort of attribute to the enemy class that either predefines its speed or alternatively have attribute that defines it as a fast enemy e.g
self.fast = True
then inside your for loop have an if statement that checks if self.fast is true and then move it at a faster speed.