diff --git a/NS.py b/NS.py index b726e64..b7427df 100644 --- a/NS.py +++ b/NS.py @@ -472,6 +472,8 @@ class Tony(Sprite): for sfx_name in self.get_audio().sfx: if sfx_name.startswith("TonyTauntsBend_"): self.taunts.append(sfx_name) + self.location.centerx = dsr.centerx + self.board.location.centerx = self.location.centerx def set_frameset(self, name): Sprite.set_frameset(self, name) @@ -495,8 +497,11 @@ class Tony(Sprite): 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 Sprite.update(self) 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) @@ -739,7 +744,7 @@ class Dialogue(Animation): Animation.__init__(self, parent) ds = self.get_display_surface() dsr = ds.get_rect() - frame = Surface((640, 72)) + frame = Surface((dsr.w, 72)) frame.fill(self.BORDER) frame.fill(self.BACKGROUND, (1, 1, frame.get_width() - 2, frame.get_height() - 2)) self.text_box = Sprite(self) @@ -946,18 +951,29 @@ class AdvancePrompt(GameChild): class Wipe(Animation): + """ + This class creates a blinds screen wipe effect that can be given a callback function to be called exactly when the screen is + filled with the wipe graphic. This allows the game to transition between states behind the wipe graphic to create a curtain + effect. + """ BLIND_COUNT = 4 SPEED = 6 - TRANSPARENT_COLOR = 255, 0, 0 def __init__(self, parent): + """ + Initialize the wipe image and sound effect + + @param parent PGFW game object that instantiated the wipe + """ Animation.__init__(self, parent) self.image = load(self.get_resource("Ink.png")).convert() - self.image.set_colorkey(self.TRANSPARENT_COLOR) self.sound = self.get_audio().sfx["wipe"] def reset(self): + """ + Deactivate and stop the animation + """ self.deactivate() self.halt() @@ -968,15 +984,24 @@ class Wipe(Animation): self.active = True def start(self, callback): + """ + Trigger the wipe animation to begin. The given callback function will be called when the screen is filled with the + wipe graphic. + + @param callback function to be called when the wipe is covering the screen + """ self.activate() self.up = True - # self.get_game().suppress_input() self.blind_height = self.get_display_surface().get_height() / self.BLIND_COUNT self.callback = callback self.play() self.sound.play() def build_frame(self): + """ + This grows and shrinks the height of the blinds that control how much of the wipe graphic is currently displayed. It + will be called automatically every frame as long as the wipe's update method is being called. + """ if self.up: self.blind_height -= self.SPEED if self.blind_height <= 0: @@ -990,18 +1015,22 @@ class Wipe(Animation): self.get_game().unsuppress_input() def update(self): + """ + Use the blind height value and screen clipping to draw the screen wipe in the state indicated by the blind height. The + screen is clipped to rects based on the blind height, and only those rects will have the wipe graphic drawn. Other screen + areas will show what is being drawn behind the screen wipe. + """ if self.active: Animation.update(self) ds = self.get_display_surface() dsr = ds.get_rect() - frame = self.image.copy() for y in range(0, dsr.h, dsr.h // self.BLIND_COUNT): if self.up: - frame.fill(self.TRANSPARENT_COLOR, (0, y, dsr.w, self.blind_height)) + ds.set_clip((0, y, dsr.w, dsr.h // self.BLIND_COUNT - self.blind_height)) else: - frame.fill(self.TRANSPARENT_COLOR, - (0, y + dsr.h / self.BLIND_COUNT - self.blind_height, dsr.w, self.blind_height)) - ds.blit(frame, (0, 0)) + ds.set_clip((0, y + self.blind_height, dsr.w, dsr.h // self.BLIND_COUNT - self.blind_height)) + ds.blit(self.image, (0, 0)) + ds.set_clip(None) class Platform(GameChild): diff --git a/config b/config index 6ebc4f5..d3f4234 100644 --- a/config +++ b/config @@ -23,14 +23,14 @@ data-exclude = local/, *.pyc, .git*, README, build/, dist/, *.egg-info, *.py, MA [display] caption = Scrapeboard show-framerate = no -dimensions = 640, 480 +dimensions = 854, 480 fullscreen = no attract-gif-alpha = 0.95 effects = yes [system] # will force set display->effects to off -minimize-load-time = no +minimize-load-time = yes [mouse] visible = no @@ -70,4 +70,4 @@ nw_color = #00FF88 ne_color = #FF88FF se_color = #2222FF sw_color = #FF2222 -center = 319, 376 +center = 427, 376 diff --git a/resource/Ink.png b/resource/Ink.png index 6524bd8..5f62d36 100644 Binary files a/resource/Ink.png and b/resource/Ink.png differ