From e86a3d2324297ccfccf5d335fbc218cca288f709 Mon Sep 17 00:00:00 2001 From: frank Date: Wed, 2 Nov 2022 23:46:48 -0400 Subject: [PATCH] toggle-able tony shirt glow effect --- NS.py | 51 +++++++++++++++++++++++++++++---------------------- config | 1 + 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/NS.py b/NS.py index 8b1a13b..2039d97 100644 --- a/NS.py +++ b/NS.py @@ -188,7 +188,7 @@ class NS(Game, Animation): "display": { "float": "attract-gif-alpha", - "bool": "effects" + "bool": ["effects", "alpha-effect-title"] }, "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 # using `pygame.BLEND_RGBA_SUB`. Skip this if fast load is requested. if not self.get_configuration("system", "minimize-load-time"): - # self.effect = Sprite(self) - self.effect = Sprite(self, 120) + if self.get_configuration("display", "alpha-effect-title"): + self.effect = Sprite(self) + else: + self.effect = Sprite(self, 120) for offset in range(12): - # w, h = dsr.w - 40, int(dsr.h * .65) - w, h = dsr.w - 120, int(dsr.h * .65) - # glow = Surface((w, h), SRCALPHA) - glow = Surface((w, h)) + if self.get_configuration("display", "alpha-effect-title"): + w, h = dsr.w - 40, int(dsr.h * .65) + glow = Surface((w, h), SRCALPHA) + else: + w, h = dsr.w - 120, int(dsr.h * .65) + glow = Surface((w, h)) for ii, y in enumerate(range(h, 0, -8)): hue = range(240, 200, -2)[(ii - offset) % 12] 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) filled_ellipse(glow, w // 2, y, w // 2 - 4, h // 20, color) self.effect.add_frame(glow) - # self.effect.location.topleft = -20, int(dsr.h * .35) - self.effect.location.midbottom = dsr.midbottom + if self.get_configuration("display", "alpha-effect-title"): + 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.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. """ # Create an intermediate surface for blending the glow with the sprite frame - # if self.get_configuration("display", "effects"): - # save = self.get_display_surface() - # intermediate_surface = Surface(self.location.size, SRCALPHA) - # self.display_surface = intermediate_surface - # location_save = self.location.copy() - # self.location.topleft = 0, 0 + if self.get_configuration("display", "alpha-effect-title"): + save = self.get_display_surface() + intermediate_surface = Surface(self.location.size, SRCALPHA) + self.display_surface = intermediate_surface + location_save = self.location.copy() + self.location.topleft = 0, 0 # Do a regular Sprite animation update Sprite.update(self) - self.effect.update(flags=BLEND_RGBA_SUB) # Blend the effect frame with the sprite frame - # if self.get_configuration("display", "effects"): - # self.display_surface = save - # self.location = location_save - # self.effect.display_surface = intermediate_surface - # self.effect.update(flags=BLEND_RGBA_SUB) - # self.get_display_surface().blit(intermediate_surface, self.location.topleft) + if self.get_configuration("display", "alpha-effect-title"): + self.display_surface = save + self.location = location_save + self.effect.display_surface = intermediate_surface + self.effect.update(flags=BLEND_RGBA_SUB) + 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 if self.get_game().title.active: diff --git a/config b/config index f90c609..923d2d8 100644 --- a/config +++ b/config @@ -27,6 +27,7 @@ dimensions = 800, 450 fullscreen = no attract-gif-alpha = 1.0 effects = True +alpha-effect-title = False [system] # will force set display->effects to off