From 2db0ff32db75f5e1c2735b793410d0ebd3b7e2a3 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Mon, 12 May 2014 21:10:02 +0200 Subject: [PATCH] It isn't always a 4/4 split --- naja/widgets/game_bits.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/naja/widgets/game_bits.py b/naja/widgets/game_bits.py index 973c2b8..de6c6be 100644 --- a/naja/widgets/game_bits.py +++ b/naja/widgets/game_bits.py @@ -20,19 +20,20 @@ class GameBitsWidget(Widget): def prepare(self): self.surface = pygame.Surface(BIT_SIZE) + health = self.state.gameboard.health + max_health = self.state.gameboard.max_health wins = self.state.gameboard.wins + wins_required = self.state.gameboard.wins_required bits = [] - bits.extend( - (i < health, 'health', (EIGHT_BIT,)) for i in range(4)) - bits.extend( - (i < wins, 'win', (EIGHT_BIT,)) for i in range(4)) + bits.extend((i < health, 'health') for i in range(max_health)) + bits.extend((i < wins, 'win') for i in range(wins_required)) - for pos, (is_set, image, transforms) in enumerate(bits): + for pos, (is_set, image) in enumerate(bits): img = resources.get_image( 'bits', '%s_%s.png' % (image, 'on' if is_set else 'off'), - transforms=transforms) + transforms=(EIGHT_BIT,)) self.surface.blit(img, (img.get_width() * pos, 0)) def draw(self, surface): -- 2.34.1