toggle-able tony shirt glow effect

This commit is contained in:
ohsqueezy 2022-11-02 23:46:48 -04:00
parent 2369def547
commit e86a3d2324
2 changed files with 30 additions and 22 deletions

51
NS.py
View File

@ -188,7 +188,7 @@ class NS(Game, Animation):
"display": "display":
{ {
"float": "attract-gif-alpha", "float": "attract-gif-alpha",
"bool": "effects" "bool": ["effects", "alpha-effect-title"]
}, },
"system": "system":
{ {
@ -787,13 +787,17 @@ class Tony(Sprite):
# Create a glowing effect object by adding glow frames to a blank Sprite. It can then be applied to the main Tony Sprite frame # Create a glowing effect object by adding glow frames to a blank Sprite. It can then be applied to the main Tony Sprite frame
# using `pygame.BLEND_RGBA_SUB`. Skip this if fast load is requested. # using `pygame.BLEND_RGBA_SUB`. Skip this if fast load is requested.
if not self.get_configuration("system", "minimize-load-time"): if not self.get_configuration("system", "minimize-load-time"):
# self.effect = Sprite(self) if self.get_configuration("display", "alpha-effect-title"):
self.effect = Sprite(self, 120) self.effect = Sprite(self)
else:
self.effect = Sprite(self, 120)
for offset in range(12): for offset in range(12):
# w, h = dsr.w - 40, int(dsr.h * .65) if self.get_configuration("display", "alpha-effect-title"):
w, h = dsr.w - 120, int(dsr.h * .65) w, h = dsr.w - 40, int(dsr.h * .65)
# glow = Surface((w, h), SRCALPHA) glow = Surface((w, h), SRCALPHA)
glow = Surface((w, h)) else:
w, h = dsr.w - 120, int(dsr.h * .65)
glow = Surface((w, h))
for ii, y in enumerate(range(h, 0, -8)): for ii, y in enumerate(range(h, 0, -8)):
hue = range(240, 200, -2)[(ii - offset) % 12] hue = range(240, 200, -2)[(ii - offset) % 12]
alpha = min(100, int(round(y / float(h - 10) * 100))) alpha = min(100, int(round(y / float(h - 10) * 100)))
@ -803,8 +807,10 @@ class Tony(Sprite):
ellipse(glow, w // 2, y, w // 2 - 4, h // 20, color) ellipse(glow, w // 2, y, w // 2 - 4, h // 20, color)
filled_ellipse(glow, w // 2, y, w // 2 - 4, h // 20, color) filled_ellipse(glow, w // 2, y, w // 2 - 4, h // 20, color)
self.effect.add_frame(glow) self.effect.add_frame(glow)
# self.effect.location.topleft = -20, int(dsr.h * .35) if self.get_configuration("display", "alpha-effect-title"):
self.effect.location.midbottom = dsr.midbottom self.effect.location.topleft = -20, int(dsr.h * .35)
else:
self.effect.location.midbottom = dsr.midbottom
self.add_frame(load(self.get_resource("Big_Tony.png")).convert_alpha()) self.add_frame(load(self.get_resource("Big_Tony.png")).convert_alpha())
self.load_from_path(self.get_resource("newTony/TonyShirtHead"), True) self.load_from_path(self.get_resource("newTony/TonyShirtHead"), True)
@ -841,24 +847,25 @@ class Tony(Sprite):
effects are off. Update title screen objects. Update the board sub-animation if it is active. effects are off. Update title screen objects. Update the board sub-animation if it is active.
""" """
# Create an intermediate surface for blending the glow with the sprite frame # Create an intermediate surface for blending the glow with the sprite frame
# if self.get_configuration("display", "effects"): if self.get_configuration("display", "alpha-effect-title"):
# save = self.get_display_surface() save = self.get_display_surface()
# intermediate_surface = Surface(self.location.size, SRCALPHA) intermediate_surface = Surface(self.location.size, SRCALPHA)
# self.display_surface = intermediate_surface self.display_surface = intermediate_surface
# location_save = self.location.copy() location_save = self.location.copy()
# self.location.topleft = 0, 0 self.location.topleft = 0, 0
# Do a regular Sprite animation update # Do a regular Sprite animation update
Sprite.update(self) Sprite.update(self)
self.effect.update(flags=BLEND_RGBA_SUB)
# Blend the effect frame with the sprite frame # Blend the effect frame with the sprite frame
# if self.get_configuration("display", "effects"): if self.get_configuration("display", "alpha-effect-title"):
# self.display_surface = save self.display_surface = save
# self.location = location_save self.location = location_save
# self.effect.display_surface = intermediate_surface self.effect.display_surface = intermediate_surface
# self.effect.update(flags=BLEND_RGBA_SUB) self.effect.update(flags=BLEND_RGBA_SUB)
# self.get_display_surface().blit(intermediate_surface, self.location.topleft) self.get_display_surface().blit(intermediate_surface, self.location.topleft)
else:
self.effect.update(flags=BLEND_RGBA_SUB)
# Update title screen objects that are drawn over this sprite # Update title screen objects that are drawn over this sprite
if self.get_game().title.active: if self.get_game().title.active:

1
config
View File

@ -27,6 +27,7 @@ dimensions = 800, 450
fullscreen = no fullscreen = no
attract-gif-alpha = 1.0 attract-gif-alpha = 1.0
effects = True effects = True
alpha-effect-title = False
[system] [system]
# will force set display->effects to off # will force set display->effects to off