Search code examples
pythonpygame

How do I kill all of the enemy sprites on the screen?


I am trying to make a second level to my game, so when you get > 100 points it will delete all of the enemy sprites on the screen and then start the next level. I don't know how to delete them all. I do have an enemy sprite group called enemies, but I dont know how to use it in relation to .kill().


Solution

  • Iterate through all sprites in the group and call .kill() on each one such as:

    for sprite in group:
        sprite.kill()