import pygame, sys pygame.init() self.rect.colliderect(sprite.rect) if pygame.sprite.spritecollideany(P1, enemies): displaysurf.fll(red) pygame.display.update () for entity in all_sprites: entity.kill() time.sleep(2) pygame.quit() sys.exit