from naja.resources import resources
from naja.resources.mutators import EIGHT_BIT
from naja.widgets.base import Widget
+from naja.widgets.text import TextWidget
class GameBitsWidget(Widget):
def prepare(self):
self.surface = pygame.Surface(BIT_SIZE)
+ size = BIT_SIZE[1]
+
+ zero = TextWidget((0, 0), '0', fontsize=24, colour='white')
+ one = TextWidget((0, 0), '1', fontsize=24, colour='white')
+ zero.prepare()
+ zero.pos = (0, (size - zero.size[1]))
+ one.pos = zero.pos
+
health = self.state.gameboard.health
max_health = self.state.gameboard.max_health
wins = self.state.gameboard.wins
'bits', '%s_%s.png' % (image, 'on' if is_set else 'off'),
transforms=(EIGHT_BIT,))
self.surface.blit(img, (img.get_width() * pos, 0))
+ if is_set:
+ one.render(self.surface)
+ else:
+ zero.render(self.surface)
+ one.pos = zero.pos = (zero.pos[0] + size, zero.pos[1])
def draw(self, surface):
surface.blit(self.surface, self.pos)
from naja.resources import resources
from naja.resources.mutators import R90, R180, R270, EIGHT_BIT
from naja.widgets.base import Widget
+from naja.widgets.text import TextWidget
class PlayerBitsWidget(Widget):
def prepare(self):
self.surface = pygame.Surface(BIT_SIZE)
+
+ size = BIT_SIZE[1]
+
+ zero = TextWidget((0, 0), '0', fontsize=24, colour='white')
+ one = TextWidget((0, 0), '1', fontsize=24, colour='white')
+ zero.prepare()
+ zero.pos = (0, (size - zero.size[1]))
+ one.pos = zero.pos
+
bits = (
(BITS.MSB, 'msb', ()),
(BITS.YELLOW, 'yellow', ()),
img = resources.get_image(
'bits', '%s_%s.png' % (image, 'on' if is_set else 'off'),
transforms=transforms + (EIGHT_BIT,))
- self.surface.blit(img, (img.get_width() * pos, 0))
+ self.surface.blit(img, (size * pos, 0))
+ if is_set:
+ one.render(self.surface)
+ else:
+ zero.render(self.surface)
+ one.pos = zero.pos = (zero.pos[0] + size, zero.pos[1])
def draw(self, surface):
surface.blit(self.surface, self.pos)