aboutsummaryrefslogtreecommitdiff
path: root/game.py
diff options
context:
space:
mode:
authorRaghuram Subramani <raghus2247@gmail.com>2023-07-30 15:03:53 +0530
committerRaghuram Subramani <raghus2247@gmail.com>2023-07-30 15:03:53 +0530
commit883e7de77e9268383cb1f5879f4499256795cccb (patch)
tree1b788442e416138f6dcf2112ee6fbb1c629cfa73 /game.py
parenta990e865d3d6408e9ddaf2ec658986e000643534 (diff)
use cockroaches_copy
Diffstat (limited to 'game.py')
-rw-r--r--game.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/game.py b/game.py
index d041444..0ec5ce0 100644
--- a/game.py
+++ b/game.py
@@ -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