]> Skullheadx's Git Forge - fruit-ninja.git/commitdiff
combo
authorSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Fri, 2 Jun 2023 16:34:01 +0000 (12:34 -0400)
committerSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Fri, 2 Jun 2023 16:34:01 +0000 (12:34 -0400)
fruit.py
game.py

index 4ab6de77c9442a0173034e6fdf0e0cc164a1f354..e29cd26d3e0935c12ed7051b3c3e39a8fdb26ab9 100644 (file)
--- a/fruit.py
+++ b/fruit.py
@@ -1,5 +1,3 @@
-import pygame
-
 from setup import *
 
 
diff --git a/game.py b/game.py
index b27f13235ecbd88687cc4fe18b32ba88f2d14a0d..d03790ee08e4fb7e554b8dc2a787de4875053747 100644 (file)
--- a/game.py
+++ b/game.py
@@ -8,6 +8,7 @@ from effect import Effect
 class Game:
     BOMB_CHANCE = 0.1
     EFFECT_COUNT_PER_FRUIT = 20
+    COMBO_TIME = 250
 
     def __init__(self):
         self.player = Player()
@@ -16,7 +17,7 @@ class Game:
         self.effects = []
         self.wave = 1
         self.score = 0
-
+        self.time_since_last_hit = 0
 
     def update(self, delta):
         for event in pygame.event.get():
@@ -34,13 +35,16 @@ class Game:
             fr = fruit.get_rect()
             if ((not -fruit.radius < fr.x < WIDTH + fruit.radius) or fr.y > HEIGHT) and fruit.velocity.y > 0:
                 self.fruits.remove(fruit)
-
+        self.time_since_last_hit += delta
         for hit in hits:
             for i in range(self.EFFECT_COUNT_PER_FRUIT):
                 self.effects.append(Effect(hit.position, hit.radius, hit.color))
             if hit in self.fruits:
                 self.fruits.remove(hit)
             self.score += 1
+            self.time_since_last_hit = 0
+        if self.time_since_last_hit < self.COMBO_TIME:
+            self.score += len(hits)
 
         for effect in self.effects:
             effect_status = effect.update(delta)