I have the following bit of code which I’m using to delete all of the sprites in the apple_list when they collide with the snake sprite. What I would like to know is what is the best way to make something happen when the snake sprite collides with a sprite from apple_list. For example, if I wanted to play a sound every time this happens, what’s the simplest way to do that?
hitApples = pygame.sprite.spritecollide(snake, apple_list, True)
Unfortunately, there is no callback manageemnt during sprite collision in pygame.
In your case, you should use something like this :