I have a group containing my aliens and another containing the bullets I have fired. When I detect their collisions, I want to pull the alien's x-y co-ordinates during it's deletion so I can put an explosion animation in that location. How do I achieve this? My attempts so far give an error saying group items cannot be indexed.
This is my first real coding project - so still new. I'm using Pygame to make the game.
Current collision detection code:
def check_bullet_alien_collisions(ai_settings,screen,stats,sb,ship,aliens,bullets,bombs): """Respond to bullet-alien collisions""" collisions = pygame.sprite.groupcollide(bullets,aliens,True,True) #Collect X-Y co-ordinates here if collisions: for aliens in collisions.values(): stats.score += ai_settings.alien_points * len(aliens) sb.prep_score() stats.aliens_hit += 1 stats.calc_accuracy() sb.accuracy() check_high_score(stats,sb)