import pygame from pygame.locals import * import sys import time pygame.init() if pygame.sprite.spritecollideany(P1, enemies): DISPLAYSURF.fill(RED) pygame.display.update() for entity in all_sprites: entity.kill() time.sleep(2) pygame.quit() sys.exit