From 28d44f768d9ff3a741b35c566bb01736c4bb530b Mon Sep 17 00:00:00 2001 From: Simon Cross Date: Sun, 11 May 2014 23:59:19 +0200 Subject: [PATCH] Implement game bits. --- naja/widgets/game_bits.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/naja/widgets/game_bits.py b/naja/widgets/game_bits.py index 78f1ab9..a5dbeae 100644 --- a/naja/widgets/game_bits.py +++ b/naja/widgets/game_bits.py @@ -19,18 +19,16 @@ class GameBitsWidget(Widget): def prepare(self): self.surface = pygame.Surface(BIT_SIZE) - bits = ( - (BITS.MSB, 'msb', ()), - (BITS.YELLOW, 'yellow', ()), - (BITS.MAGENTA, 'magenta', ()), - (BITS.CYAN, 'cyan', ()), - (BITS.WEST, 'arrow', ()), - (BITS.EAST, 'arrow', ()), - (BITS.SOUTH, 'arrow', ()), - (BITS.NORTH, 'arrow', ()), - ) - for pos, (bit, image, transforms) in enumerate(bits): - is_set = self.state.player.bits.check_bit(bit) + health = self.state.gameboard.health + wins = self.state.gameboard.wins + + bits = [] + bits.extend( + (i < health, 'health', ()) for i in range(4)) + bits.extend( + (i < wins, 'win', ()) for i in range(4)) + + for pos, (is_set, image, transforms) in enumerate(bits): img = resources.get_image( 'bits', '%s_%s.png' % (image, 'on' if is_set else 'off'), transforms=transforms) -- 2.34.1