0

I'm using the following:

hit = pygame.sprite.spritecollide(player, door_list, False)

Is there any way of checking with what element in door_list the player collided with?

OTheDev
  • 2,916
  • 2
  • 4
  • 20
  • 1
    [how do I detect collision in pygame](https://stackoverflow.com/questions/29640685/how-do-i-detect-collision-in-pygame) may be helpful – Patrick Artner Apr 27 '22 at 14:10
  • `google pygame detect collision site:stackoverflow.com` should give you _plenty_ resources to read through - there are also dozends of tutorials on collision searchable ... why ask here? – Patrick Artner Apr 27 '22 at 14:10
  • 1
    [pygame-sprite-collision-with-sprite-group](https://stackoverflow.com/questions/43474849/pygame-sprite-collision-with-sprite-group) may be helpful read – Patrick Artner Apr 27 '22 at 14:12

1 Answers1

0

pygame.sprite.spritecollide returns a list containing all Sprites in a _Group: that intersect with another Sprite:

hit_doors = pygame.sprite.spritecollide(player, door_list, False)
for door in hit_doors:
    # do something
    # [...]
Rabbid76
  • 202,892
  • 27
  • 131
  • 174