diff options
author | Raghuram Subramani <raghus2247@gmail.com> | 2023-07-30 15:03:53 +0530 |
---|---|---|
committer | Raghuram Subramani <raghus2247@gmail.com> | 2023-07-30 15:03:53 +0530 |
commit | 883e7de77e9268383cb1f5879f4499256795cccb (patch) | |
tree | 1b788442e416138f6dcf2112ee6fbb1c629cfa73 /game.py | |
parent | a990e865d3d6408e9ddaf2ec658986e000643534 (diff) |
use cockroaches_copy
Diffstat (limited to 'game.py')
-rw-r--r-- | game.py | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -57,8 +57,10 @@ class MyGame: self.asteroids.remove(asteroid) def detect_collision(self, x, y): + cockroaches_copy = self.cockroaches.copy() + # Iterate through the list of cockroaches - for cockroach in self.cockroaches: + for cockroach in cockroaches_copy: # Check if the detection rectangle intersects with the cockroach if x < cockroach.x < x + self.w and y < cockroach.y < y + self.h: # Remove the cockroach from the list |