This commit is contained in:
Frank DeMarco 2017-12-25 03:48:36 -05:00
parent 8efebb8e26
commit 0a54991051
3 changed files with 28 additions and 11 deletions

39
NS.py
View File

@ -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)

BIN
resource/HUD_background.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 712 B

BIN
resource/HUD_bar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 418 B