X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=naja%2Fwidgets%2Fgame_bits.py;h=78f1ab91f488ef7ff275e7041ded574bc933f808;hb=85f20ca165c1710c96afbc42fa07acb68b6b4c1d;hp=682d520531a366790727212ac3786dc2c35d46da;hpb=85cfc03ea79f3d3de4210c76b32bd61d810c7f92;p=naja.git diff --git a/naja/widgets/game_bits.py b/naja/widgets/game_bits.py index 682d520..78f1ab9 100644 --- a/naja/widgets/game_bits.py +++ b/naja/widgets/game_bits.py @@ -2,7 +2,10 @@ Widget that holds the games's bits. """ -from naja.constants import BIT_SIZE +import pygame + +from naja.constants import BIT_SIZE, BITS +from naja.resources import resources from naja.widgets.base import Widget @@ -10,12 +13,28 @@ class GameBitsWidget(Widget): """ Widget which holds the game's bits. """ - def __init__(self, pos, image=None): + def __init__(self, pos, state): super(GameBitsWidget, self).__init__(pos, BIT_SIZE) + self.state = state def prepare(self): - pass + 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) + 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): - pass - #surface.blit(self.surface, self.pos) + surface.blit(self.surface, self.pos)