diff --git a/NS.py b/NS.py index 6886582..110039e 100644 --- a/NS.py +++ b/NS.py @@ -906,7 +906,7 @@ class Boss(RainbowSprite): dialogue = self.get_game().dialogue dialogue.activate() dialogue.show_text("You'll never be able to block my sword, you lizard slime!" + - " See if you\ncan keep up with these moves!") + " See if you\ncan keep up with these moves!") def reset(self): self.deactivate() @@ -966,6 +966,7 @@ class Boss(RainbowSprite): else: self.get_game().dialogue.deactivate() self.combo() + self.advance_prompt.cancel_first_press() RainbowSprite.update(self) # self.get_display_surface().blit(self.image, (0, 0)) self.sword.update() @@ -1039,12 +1040,20 @@ class Sword(Sprite): class Health(GameChild): - WIDTH = 200 - HEIGHT = 32 - COLOR = "yellow" + TEXT = "HP" + BAR_POSITION = 23, 11 + BACKGROUND_ALPHA = 125 def __init__(self, parent): GameChild.__init__(self, parent) + self.background = Sprite(self) + self.background.load_from_path(self.get_resource("HUD_background.png"), True) + self.label = Sprite(self) + font = Font(self.get_resource("rounded-mplus-1m-bold.ttf"), 24) + text = font.render(self.TEXT, True, Color("white")) + self.label.add_frame(text) + self.label.location.topleft = 2, -2 + self.bar = load(self.get_resource("HUD_bar.png")).convert_alpha() def reset(self): self.amount = 100 @@ -1059,10 +1068,18 @@ class Health(GameChild): self.parent.set_frameset(0) def update(self): - surface = Surface((int(self.WIDTH * (self.amount / 100.0)), self.HEIGHT)) - surface.fill(Color(self.COLOR)) - surface.set_alpha(255) - font = Font(self.get_resource("rounded-mplus-1m-bold.ttf"), 14) - text = font.render("HEALTH", True, Color("black")) - # surface.blit(text, (8, 0)) - self.get_display_surface().blit(surface, (0, 0)) + self.background.update() + self.label.update() + if self.amount > 50: + color = 0, 255, 0 + elif self.amount > 25: + color = Color("orange") + else: + color = Color("red") + mask = Surface(self.bar.get_size(), SRCALPHA) + mask.fill((128, 128, 128)) + mask.fill(color, (0, 0, int(mask.get_width() * (self.amount / 100.0)), + mask.get_height())) + surface = self.bar.copy() + surface.blit(mask, (0, 0), None, BLEND_RGBA_MIN) + self.get_display_surface().blit(surface, self.BAR_POSITION) diff --git a/resource/HUD_background.png b/resource/HUD_background.png new file mode 100644 index 0000000..3cf2faa Binary files /dev/null and b/resource/HUD_background.png differ diff --git a/resource/HUD_bar.png b/resource/HUD_bar.png new file mode 100644 index 0000000..9c35dd2 Binary files /dev/null and b/resource/HUD_bar.png differ