From 8deb08d9b12aec60bb19d795d9320b6f9a18d0e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Sun, 31 Aug 2014 01:52:54 +0200 Subject: [PATCH] Cleanup the avocado generation --- avocado.py | 9 --------- game.py | 3 ++- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/avocado.py b/avocado.py index 4e9da39..9000882 100644 --- a/avocado.py +++ b/avocado.py @@ -7,15 +7,6 @@ class Avocado: def __init__(self, screen, color, size, target, filename='img/AvoCado_0.png'): - # HELP please!! - # We randomly decide whether we should instanciate or not - # I'd rather just not return an instance, - # but I don't know how to do that :( - if random.randint(0,40) != 1: - self.is_still_falling = False - self.has_been_pinned = False - return None - # Set up our instance variables self.screen = screen self.color = color diff --git a/game.py b/game.py index 1887029..6ec6b69 100755 --- a/game.py +++ b/game.py @@ -168,7 +168,8 @@ class TheGame: avocados_in_game = len(avocados) avocadosWanted = level * multiplier if avocados_in_game < avocadosWanted: - for i in range(avocados_in_game, avocadosWanted): + blah = int(1.0/(avocadosWanted - avocados_in_game) * 100) + if random.randint(0, blah) == 1: avocolor = self.chooseRandomColor() avosize = (50, 50) # should we randomize this? a = avocado.Avocado(self.screen, avocolor, avosize, color)