bar
This commit is contained in:
parent
5802b1f12d
commit
b94d9b49c3
45
NS.py
45
NS.py
|
@ -25,8 +25,10 @@ from lib.pgfw.pgfw.GameChild import GameChild
|
|||
from lib.pgfw.pgfw.Sprite import Sprite, RainbowSprite
|
||||
from lib.pgfw.pgfw.Animation import Animation
|
||||
from lib.pgfw.pgfw.Audio import SoundEffect
|
||||
from lib.pgfw.pgfw.extension import (get_step, get_step_relative, get_delta, reflect_angle,
|
||||
render_box, get_hsla_color)
|
||||
from lib.pgfw.pgfw.extension import (
|
||||
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
|
||||
|
||||
class NS(Game, Animation):
|
||||
|
@ -1608,11 +1610,19 @@ class Health(GameChild):
|
|||
TEXT = "BOSS"
|
||||
BAR_POSITION = 23, 11
|
||||
BACKGROUND_ALPHA = 125
|
||||
OFFSET = 11
|
||||
|
||||
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.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)
|
||||
font = Font(self.get_resource("rounded-mplus-1m-bold.ttf"), 24)
|
||||
text = font.render(self.TEXT, True, Color("white"))
|
||||
|
@ -1635,20 +1645,27 @@ class Health(GameChild):
|
|||
|
||||
def update(self):
|
||||
self.background.update()
|
||||
self.label.update()
|
||||
# self.label.update()
|
||||
if self.amount > 50:
|
||||
color = 0, 255, 0
|
||||
shift = 0
|
||||
elif self.amount > 25:
|
||||
color = Color("orange")
|
||||
shift = -70
|
||||
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)
|
||||
shift = -120
|
||||
# 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)
|
||||
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):
|
||||
|
|
2
config
2
config
|
@ -9,7 +9,7 @@ data-exclude = local/, *.pyc
|
|||
|
||||
[display]
|
||||
caption = Electric Scrapeboard
|
||||
show-framerate = False
|
||||
show-framerate = yes
|
||||
dimensions = 640, 480
|
||||
fullscreen = no
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 191 B |
Binary file not shown.
After Width: | Height: | Size: 478 B |
Loading…
Reference in New Issue