From: Skullheadx <94652084+Skullheadx@users.noreply.github.com> Date: Fri, 2 Jun 2023 16:34:01 +0000 (-0400) Subject: combo X-Git-Tag: game~19 X-Git-Url: http://git.skullheadx.com/now.html?a=commitdiff_plain;h=bd33fcc7176c81f784d87315186012954f219c9b;p=fruit-ninja.git combo --- diff --git a/fruit.py b/fruit.py index 4ab6de7..e29cd26 100644 --- a/fruit.py +++ b/fruit.py @@ -1,5 +1,3 @@ -import pygame - from setup import * diff --git a/game.py b/game.py index b27f132..d03790e 100644 --- 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)