2 Widget that holds the games's bits.
7 from naja.constants import BIT_SIZE
8 from naja.resources import resources
9 from naja.resources.mutators import EIGHT_BIT
10 from naja.widgets.base import Widget
13 class GameBitsWidget(Widget):
15 Widget which holds the game's bits.
17 def __init__(self, pos, state):
18 super(GameBitsWidget, self).__init__(pos, BIT_SIZE)
22 self.surface = pygame.Surface(BIT_SIZE)
23 health = self.state.gameboard.health
24 wins = self.state.gameboard.wins
28 (i < health, 'health', (EIGHT_BIT,)) for i in range(4))
30 (i < wins, 'win', (EIGHT_BIT,)) for i in range(4))
32 for pos, (is_set, image, transforms) in enumerate(bits):
33 img = resources.get_image(
34 'bits', '%s_%s.png' % (image, 'on' if is_set else 'off'),
35 transforms=transforms)
36 self.surface.blit(img, (img.get_width() * pos, 0))
38 def draw(self, surface):
39 surface.blit(self.surface, self.pos)