X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=naja%2Fwidgets%2Fgame_bits.py;h=973c2b80f20abd80f524d002554b173995977088;hb=4354fb84c1cc1c778e3e7d2a4d487fb1c86a8ad4;hp=21756586bf80276ea1ea28f072c81b252c22e81c;hpb=6fad179c71412061cd4b1cc4d79e407ccc47780f;p=naja.git diff --git a/naja/widgets/game_bits.py b/naja/widgets/game_bits.py index 2175658..973c2b8 100644 --- a/naja/widgets/game_bits.py +++ b/naja/widgets/game_bits.py @@ -4,7 +4,9 @@ Widget that holds the games's bits. import pygame -from naja.constants import BIT_SIZE, BITS +from naja.constants import BIT_SIZE +from naja.resources import resources +from naja.resources.mutators import EIGHT_BIT from naja.widgets.base import Widget @@ -18,6 +20,20 @@ class GameBitsWidget(Widget): def prepare(self): self.surface = pygame.Surface(BIT_SIZE) + health = self.state.gameboard.health + wins = self.state.gameboard.wins + + 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)) + + 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) + self.surface.blit(img, (img.get_width() * pos, 0)) def draw(self, surface): surface.blit(self.surface, self.pos)