Created
June 12, 2021 18:09
-
-
Save PatrickKalkman/97d14e5719dc57b33e20439a8a22285a to your computer and use it in GitHub Desktop.
using group collide to detect collisions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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