This commit is contained in:
Frank DeMarco 2018-07-10 00:57:27 -04:00
parent 5802b1f12d
commit b94d9b49c3
4 changed files with 32 additions and 15 deletions

45
NS.py
View File

@ -25,8 +25,10 @@ from lib.pgfw.pgfw.GameChild import GameChild
from lib.pgfw.pgfw.Sprite import Sprite, RainbowSprite from lib.pgfw.pgfw.Sprite import Sprite, RainbowSprite
from lib.pgfw.pgfw.Animation import Animation from lib.pgfw.pgfw.Animation import Animation
from lib.pgfw.pgfw.Audio import SoundEffect from lib.pgfw.pgfw.Audio import SoundEffect
from lib.pgfw.pgfw.extension import (get_step, get_step_relative, get_delta, reflect_angle, from lib.pgfw.pgfw.extension import (
render_box, get_hsla_color) get_step, get_step_relative, get_delta, reflect_angle,
render_box, get_hsla_color, get_hue_shifted_surface
)
from lib.pgfw.pgfw.gfx_extension import aa_filled_polygon from lib.pgfw.pgfw.gfx_extension import aa_filled_polygon
class NS(Game, Animation): class NS(Game, Animation):
@ -1608,11 +1610,19 @@ class Health(GameChild):
TEXT = "BOSS" TEXT = "BOSS"
BAR_POSITION = 23, 11 BAR_POSITION = 23, 11
BACKGROUND_ALPHA = 125 BACKGROUND_ALPHA = 125
OFFSET = 11
def __init__(self, parent): def __init__(self, parent):
GameChild.__init__(self, parent) GameChild.__init__(self, parent)
# self.background = Sprite(self)
# self.background.load_from_path(self.get_resource("HUD_background.png"), True)
self.background = Sprite(self) self.background = Sprite(self)
self.background.load_from_path(self.get_resource("HUD_background.png"), True) self.background.load_from_path(self.get_resource("HUD_boss_health_background.png"), True)
dsr = self.get_display_surface().get_rect()
self.background.location.center = dsr.centerx, self.OFFSET
self.foreground = Sprite(self)
self.foreground.load_from_path(self.get_resource("HUD_boss_health_foreground.png"), True)
self.foreground.location.center = dsr.centerx, self.OFFSET
self.label = Sprite(self) self.label = Sprite(self)
font = Font(self.get_resource("rounded-mplus-1m-bold.ttf"), 24) font = Font(self.get_resource("rounded-mplus-1m-bold.ttf"), 24)
text = font.render(self.TEXT, True, Color("white")) text = font.render(self.TEXT, True, Color("white"))
@ -1635,20 +1645,27 @@ class Health(GameChild):
def update(self): def update(self):
self.background.update() self.background.update()
self.label.update() # self.label.update()
if self.amount > 50: if self.amount > 50:
color = 0, 255, 0 shift = 0
elif self.amount > 25: elif self.amount > 25:
color = Color("orange") shift = -70
else: else:
color = Color("red") shift = -120
mask = Surface(self.bar.get_size(), SRCALPHA) # mask = Surface(self.bar.get_size(), SRCALPHA)
mask.fill((128, 128, 128)) # mask.fill((128, 128, 128))
mask.fill(color, (0, 0, int(mask.get_width() * (self.amount / 100.0)), # mask.fill(color, (0, 0, int(mask.get_width() * (self.amount / 100.0)),
mask.get_height())) # mask.get_height()))
surface = self.bar.copy() # surface = self.bar.copy()
surface.blit(mask, (0, 0), None, BLEND_RGBA_MIN) # surface.blit(mask, (0, 0), None, BLEND_RGBA_MIN)
self.get_display_surface().blit(surface, self.BAR_POSITION) # self.get_display_surface().blit(surface, self.BAR_POSITION)
ratio = self.amount / 100.0
ds = self.get_display_surface()
ds.set_clip((self.foreground.location.left, self.foreground.location.top,
int(self.foreground.location.w * ratio), self.foreground.location.h))
surface = get_hue_shifted_surface(self.foreground.get_current_frame(), shift)
ds.blit(surface, self.foreground.location.topleft)
ds.set_clip(None)
class Ending(Animation): class Ending(Animation):

2
config
View File

@ -9,7 +9,7 @@ data-exclude = local/, *.pyc
[display] [display]
caption = Electric Scrapeboard caption = Electric Scrapeboard
show-framerate = False show-framerate = yes
dimensions = 640, 480 dimensions = 640, 480
fullscreen = no fullscreen = no

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 B