wkeeling/arkanoid

Switch to using generator expressions for sprite collision detection

Opened this issue · 0 comments

Rather than creating temporary lists when filtering sprites for collision detection, use generator expressions. This is more efficient as it means that fewer lists have to be created in memory.

e.g.

sprites_collided = pygame.sprite.spritecollide(self, (s for s in self._collidable_sprites if s.visible), False)