Skip to content

Commit

Permalink
Rewrite groupcollide function
Browse files Browse the repository at this point in the history
  • Loading branch information
aatle committed Nov 3, 2024
1 parent 7d27a8b commit 09e70e1
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src_py/sprite.py
Original file line number Diff line number Diff line change
Expand Up @@ -1723,17 +1723,13 @@ def groupcollide(groupa, groupb, dokilla, dokillb, collided=None):
# pull the collision function in as a local variable outside
# the loop as this makes the loop run faster
sprite_collide_func = spritecollide
for group_a_sprite in groupa:
collisions = sprite_collide_func(group_a_sprite, groupb, dokillb, collided)
if collisions:
crashed[group_a_sprite] = collisions
if dokilla:
for group_a_sprite in groupa.sprites():
collision = sprite_collide_func(group_a_sprite, groupb, dokillb, collided)
if collision:
crashed[group_a_sprite] = collision
group_a_sprite.kill()
else:
for group_a_sprite in groupa:
collision = sprite_collide_func(group_a_sprite, groupb, dokillb, collided)
if collision:
crashed[group_a_sprite] = collision
for group_a_sprite in crashed:
group_a_sprite.kill()
return crashed


Expand Down

0 comments on commit 09e70e1

Please sign in to comment.