Skip to content

Instantly share code, notes, and snippets.

@PatrickKalkman
Created June 12, 2021 18:09
Show Gist options
  • Save PatrickKalkman/97d14e5719dc57b33e20439a8a22285a to your computer and use it in GitHub Desktop.
Save PatrickKalkman/97d14e5719dc57b33e20439a8a22285a to your computer and use it in GitHub Desktop.
using group collide to detect collisions
result = pygame.sprite.groupcollide(self.all_rockets, self.all_enemies, True, True)
if result:
for key in result:
self.score += 120
if self.score > self.high_score:
self.high_score = self.score
self.all_sprites.add(Explosion(self.explosion_sprites, key.rect[0], key.rect[1]))
self.kill_sound.play()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment