title: How do I find position of sprite in group?
body: <p>I'm making a game in pygame and am trying to figure out a way to make the enemies explode.</p>
  
  <p>Enemies have their class:</p>
  
  <pre><code>class Enemy(pygame.sprite.Sprite):
  
      def __init__(enemy, x, y):
          pygame.sprite.Sprite.__init__(enemy)
          enemy.image = ENEMYIMAGE.convert()
          enemy.mask = pygame.mask.from_surface(enemy.image)
          enemy.rect = enemy.image.get_rect()
          enemy.rect.x = x
          enemy.rect.y = y
  </code></pre>
  
  <p>Which is called in main() repeatedly, then added to a group:</p>
  
  <pre><code>enemy_group = pygame.sprite.Group()
  if spawn_ctr % 700 == 0:
          enemy = Enemy(WINDOWWIDTH, (random.randint(0, WINDOWHEIGHT - ENEMYHEIGHT)))
          enemy_group.add(enemy)
      spawn_ctr += 1
  </code></pre>
  
  <p>Lasers are made similarly, that is, there is a Laser class which is called in main(). When the class is called the Laser is added to a group.</p>
  
  <p>My attempt at making the enemies explode:</p>
  
  <pre><code>if pygame.sprite.groupcollide(weapon_group, enemy_group, False, True):
      EXPLOSIONSOUND.play()
      EXPLOSIONANIM.play()
      EXPLOSIONANIM.blit(screen, (weapon.rect.x, weapon.rect.y))
  </code></pre>
  
  <p>This does remove the enemy from the group, making it so that</p>
  
  <pre><code>enemy_group.draw(screen)
  </code></pre>
  
  <p>does not draw the enemy which was shot and killed.</p>
  
  <p>But, the explosion actually occurs at the player. How might someone rewrite this in a better way?</p>