]> Skullheadx's Git Forge - fruit-ninja.git/commitdiff
remove extra rect when player slice
authorSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Thu, 1 Jun 2023 17:59:12 +0000 (13:59 -0400)
committerSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Thu, 1 Jun 2023 17:59:12 +0000 (13:59 -0400)
player.py

index d134bbd97a6803385626d59ebce4f78412169724..0e08b5616a3c4674daaf9cf5a804f50ce66b598f 100644 (file)
--- a/player.py
+++ b/player.py
@@ -19,8 +19,8 @@ class Player:
             if pygame.time.get_ticks() - time > self.LIFE_TIME:
                 self.sliced_points.pop(i)
                 break
+        self.hitboxes.clear()
         if len(self.sliced_points) > 1:
-            self.hitboxes.clear()
             for i in range(len(self.sliced_points) - 1):
                 self.hitboxes.append(pygame.Rect(self.sliced_points[i][0],
                                                  (self.sliced_points[i][0] - self.sliced_points[i + 1][0])).inflate(
@@ -33,9 +33,9 @@ class Player:
         return False
 
     def draw(self, surf):
-        for hitbox in self.hitboxes:
-            pygame.draw.rect(surf, RED, hitbox)
+        for hitbox in self.hitboxes:
+            pygame.draw.rect(surf, RED, hitbox)
         # for pos, time in self.sliced_points:
         #     pygame.draw.circle(surf, RED, pos, 10)
-        if len(self.sliced_points) > 1:
-            pygame.draw.lines(surf, BLACK, False, [a for a, b in self.sliced_points], 3)
+        if len(self.sliced_points) > 1:
+            pygame.draw.lines(surf, BLACK, False, [a for a, b in self.sliced_points], 3)