2 Widget that holds the games's bits.
7 from naja.constants import BIT_SIZE, BITS
8 from naja.resources import resources
9 from naja.widgets.base import Widget
12 class GameBitsWidget(Widget):
14 Widget which holds the game's bits.
16 def __init__(self, pos, state):
17 super(GameBitsWidget, self).__init__(pos, BIT_SIZE)
21 self.surface = pygame.Surface(BIT_SIZE)
23 (BITS.MSB, 'msb', ()),
24 (BITS.YELLOW, 'yellow', ()),
25 (BITS.MAGENTA, 'magenta', ()),
26 (BITS.CYAN, 'cyan', ()),
27 (BITS.WEST, 'arrow', ()),
28 (BITS.EAST, 'arrow', ()),
29 (BITS.SOUTH, 'arrow', ()),
30 (BITS.NORTH, 'arrow', ()),
32 for pos, (bit, image, transforms) in enumerate(bits):
33 is_set = self.state.player.bits.check_bit(bit)
34 img = resources.get_image(
35 'bits', '%s_%s.png' % (image, 'on' if is_set else 'off'),
36 transforms=transforms)
37 self.surface.blit(img, (img.get_width() * pos, 0))
39 def draw(self, surface):
40 surface.blit(self.surface, self.pos)