I've been programming a game from a book called "python crash course". This game is about a ship that fires against aliens. I've been trying to implement a function to detect collision between any bullet sprite and any alien sprite in a group. The problem is when a collision is detected it kills the sprite that got hit and all the other aliens vanish afterward
The funcion:
def _check_bullet_alien_collision(self):
"""Check for any bullets that have hit aliens.
If so, get rid of the bullet and the alien."""
collisions = pygame.sprite.groupcollide(
self.bullets, self.aliens, True, True)
I printed the dictionary "collisions" in order to show what happens and this is the result:
<Bullet Sprite(in 0 groups)> [<Alien Sprite(in 0 groups)>]
I've also tried to loop through the sprites and pass a single sprite as argument using another function which I forgot the name but no success.
Here is the project: https://github.com/thiagorizzi/Alien-Invasion