implemented death animations, added ordinal rank, added swords to ending

This commit is contained in:
frank 2022-03-15 21:52:02 -04:00
parent fdba749b43
commit e7c39d3e8b
9 changed files with 75 additions and 16 deletions

74
NS.py
View File

@ -34,6 +34,7 @@ from lib.pgfw.pgfw.Game import Game
from lib.pgfw.pgfw.GameChild import GameChild 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.Vector import Vector
from lib.pgfw.pgfw.extension import ( from lib.pgfw.pgfw.extension import (
get_step, get_step_relative, get_delta, reflect_angle, get_distance, render_box, get_hsla_color, get_hue_shifted_surface, get_step, get_step_relative, get_delta, reflect_angle, get_distance, render_box, get_hsla_color, get_hue_shifted_surface,
get_color_swapped_surface, load_frames, fill_colorkey, get_segments, get_boxed_surface get_color_swapped_surface, load_frames, fill_colorkey, get_segments, get_boxed_surface
@ -237,12 +238,12 @@ class NS(Game, Animation):
self.tony = Tony(self) self.tony = Tony(self)
self.logo = Logo(self) self.logo = Logo(self)
self.title = Title(self) self.title = Title(self)
self.ending = Ending(self)
self.wipe = Wipe(self) self.wipe = Wipe(self)
self.dialogue = Dialogue(self) self.dialogue = Dialogue(self)
self.chemtrails = Chemtrails(self) self.chemtrails = Chemtrails(self)
self.boss = Boss(self) self.boss = Boss(self)
self.level_select = LevelSelect(self) self.level_select = LevelSelect(self)
self.ending = Ending(self)
self.last_press = get_ticks() self.last_press = get_ticks()
self.register(self.blink_score, interval=500) self.register(self.blink_score, interval=500)
self.register(self.close_pop_up) self.register(self.close_pop_up)
@ -326,11 +327,11 @@ class NS(Game, Animation):
self.title.reset() self.title.reset()
if not leave_wipe_running: if not leave_wipe_running:
self.wipe.reset() self.wipe.reset()
self.ending.reset()
self.boss.reset() self.boss.reset()
self.chemtrails.reset() self.chemtrails.reset()
self.platform.reset() self.platform.reset()
self.dialogue.reset() self.dialogue.reset()
self.ending.reset()
self.no_reset_elapsed = 0 self.no_reset_elapsed = 0
self.title.activate() self.title.activate()
@ -1773,9 +1774,10 @@ class Chemtrails(Sprite):
self.set_frameset(NS.N) self.set_frameset(NS.N)
self.orient() self.orient()
def update(self): def update(self, offset: Vector=(0, 0)):
if self.active: if self.active:
self.orient() self.orient()
self.location.move(offset)
Sprite.update(self) Sprite.update(self)
if not self.get_game().title.active and not self.get_game().level_select.active: if not self.get_game().title.active and not self.get_game().level_select.active:
boss = self.get_game().boss boss = self.get_game().boss
@ -1961,6 +1963,9 @@ class Boss(Animation):
self.boss_sprites[-1].load_from_path(path.joinpath(f"{prefix}Boil"), True) self.boss_sprites[-1].load_from_path(path.joinpath(f"{prefix}Boil"), True)
self.boss_sprites[-1].add_frameset(name="hurt", switch=True) self.boss_sprites[-1].add_frameset(name="hurt", switch=True)
self.boss_sprites[-1].load_from_path(path.joinpath(f"{prefix}Hit"), True) self.boss_sprites[-1].load_from_path(path.joinpath(f"{prefix}Hit"), True)
if path.joinpath(f"{prefix}Death").exists():
self.boss_sprites[-1].add_frameset(name="death", switch=True)
self.boss_sprites[-1].load_from_path(path.joinpath(f"{prefix}Death"), True)
self.boss_sprites[-1].add_frameset(name="entrance", switch=True) self.boss_sprites[-1].add_frameset(name="entrance", switch=True)
self.boss_sprites[-1].load_from_path(path.joinpath(f"{prefix}Intro"), True) self.boss_sprites[-1].load_from_path(path.joinpath(f"{prefix}Intro"), True)
self.boss_sprites[-1].location.topleft = 207, 10 self.boss_sprites[-1].location.topleft = 207, 10
@ -2333,7 +2338,10 @@ class Boss(Animation):
self.queue = [] self.queue = []
self.brandish_complete = True self.brandish_complete = True
if win: if win:
self.level_sprite().set_frameset("hurt") if "death" in [str(frameset) for frameset in self.level_sprite().framesets]:
self.level_sprite().set_frameset("death")
else:
self.level_sprite().set_frameset("hurt")
if self.get_configuration("system", "enable-level-select"): if self.get_configuration("system", "enable-level-select"):
self.get_game().add_time_to_scores(self.time_elapsed, self.level_index) self.get_game().add_time_to_scores(self.time_elapsed, self.level_index)
elif self.level_index == 2: elif self.level_index == 2:
@ -2889,23 +2897,24 @@ class Ending(Animation):
def __init__(self, parent): def __init__(self, parent):
Animation.__init__(self, parent) Animation.__init__(self, parent)
self.slime_bag = Sprite(self) self.slime_bag = Chemtrails(self)
self.slime_bag.load_from_path(self.get_resource("Introduction_slime_bag.png"), True)
self.slime_bag.location.center = self.get_display_surface().get_rect().centerx, 300
self.tony_avatar = load(self.get_resource("Introduction_tony_avatar.png")).convert() self.tony_avatar = load(self.get_resource("Introduction_tony_avatar.png")).convert()
self.time_font = Font(self.get_resource("rounded-mplus-1m-bold.ttf"), 64) self.time_font = Font(self.get_resource("rounded-mplus-1m-bold.ttf"), 64)
self.rank_font = Font(self.get_resource("rounded-mplus-1m-bold.ttf"), 18) self.rank_font = Font(self.get_resource("rounded-mplus-1m-bold.ttf"), 26)
self.register(self.start, self.start_wipe) self.register(self.start, self.start_wipe)
self.register(self.append_sword, interval=1500)
self.swords = []
def reset(self): def reset(self):
self.deactivate() self.deactivate()
self.slime_bag.unhide()
self.halt() self.halt()
self.text_index = 0 self.text_index = 0
self.angle = choice((pi / 4, 3 * pi / 4, 5 * pi / 4, 7 * pi / 4)) self.angle = choice((pi / 4, 3 * pi / 4, 5 * pi / 4, 7 * pi / 4))
self.slime_bag.reset()
def deactivate(self): def deactivate(self):
self.active = False self.active = False
self.slime_bag.deactivate()
def activate(self, level_index): def activate(self, level_index):
self.defeated_level_index = level_index self.defeated_level_index = level_index
@ -2913,11 +2922,22 @@ class Ending(Animation):
self.play(self.start, delay=3000, play_once=True) self.play(self.start, delay=3000, play_once=True)
foreground = get_boxed_surface( foreground = get_boxed_surface(
self.time_font.render(str(self.get_game().most_recent_score), False, (180, 150, 20), (255, 255, 255)).convert_alpha(), self.time_font.render(str(self.get_game().most_recent_score), False, (180, 150, 20), (255, 255, 255)).convert_alpha(),
background=(255, 255, 255), padding=(30, 0)) background=(255, 255, 255), padding=(38, 0))
rank = self.rank_font.render(f"rank {self.rank()}", False, (180, 150, 20), (255, 255, 255)) if self.rank() % 100 // 10 != 1:
rank = pygame.transform.rotate(rank, 270) if self.rank() % 10 == 1:
ordinal = "ST"
elif self.rank() % 10 == 2:
ordinal = "ND"
elif self.rank() % 10 == 3:
ordinal = "RD"
else:
ordinal = "TH"
else:
ordinal = "TH"
rank = self.rank_font.render(f"{self.rank()}{ordinal}", False, (180, 150, 20), (255, 255, 255))
rank = pygame.transform.rotate(rank, 90)
rank_rect = rank.get_rect() rank_rect = rank.get_rect()
rank_rect.midright = foreground.get_rect().midright rank_rect.midleft = foreground.get_rect().midleft
foreground.blit(rank, rank_rect) foreground.blit(rank, rank_rect)
dsr = self.get_display_surface().get_rect() dsr = self.get_display_surface().get_rect()
self.text = RainbowSprite(self, foreground, 180, 200) self.text = RainbowSprite(self, foreground, 180, 200)
@ -2930,6 +2950,8 @@ class Ending(Animation):
dialogue.show_text("") dialogue.show_text("")
self.play(self.start_wipe, delay=20000, play_once=True) self.play(self.start_wipe, delay=20000, play_once=True)
self.get_audio().play_bgm("end") self.get_audio().play_bgm("end")
self.slime_bag.activate()
self.play(self.append_sword)
def rank(self): def rank(self):
""" """
@ -2965,7 +2987,25 @@ class Ending(Animation):
def start_wipe(self): def start_wipe(self):
self.get_game().wipe.start(self.end_game) self.get_game().wipe.start(self.end_game)
def append_sword(self):
"""
Add a sword to the list based on what button is pressed. Remove swords that are out of view.
"""
if self.get_game().platform.get_edge_pressed() is not None:
sprite = Sprite(self)
# Add frames from Boss->Sword storage
for frame in self.get_game().boss.sword.swords[0][self.get_game().platform.get_edge_pressed()]:
sprite.add_frame(frame)
sprite.location.center = self.slime_bag.location.center
self.swords.append(sprite)
outgoing = []
for sword in self.swords:
if sword.location.bottom < 0:
outgoing.append(sword)
for sword in outgoing:
self.swords.remove(sword)
def update(self): def update(self):
if self.active: if self.active:
Animation.update(self) Animation.update(self)
@ -2973,7 +3013,11 @@ class Ending(Animation):
wipe = self.get_game().wipe wipe = self.get_game().wipe
self.get_game().logo.update() self.get_game().logo.update()
self.get_game().tony.update() self.get_game().tony.update()
self.slime_bag.update() # Draw swords shot at Tony
for sword in self.swords:
sword.move(0, -5)
sword.update()
self.slime_bag.update(offset=(0, -30))
dsr = self.get_display_surface().get_rect() dsr = self.get_display_surface().get_rect()
# Bounce the time sprite around the screen # Bounce the time sprite around the screen
if self.text.location.right > dsr.right or self.text.location.left < dsr.left: if self.text.location.right > dsr.right or self.text.location.left < dsr.left:

@ -1 +1 @@
Subproject commit 7329aa76937b5fd225bb561459a2f5c70a57819d Subproject commit 72866bd11c07ae50ef4fbaae683200e6bb9007b5

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -1,10 +1,25 @@
10202 0 10202 0
10317 0 10317 0
10403 0 10403 0
10411 0
10417 0
10434 0
16483 0 16483 0
21640 0
24404 0 24404 0
33896 0
59424 0 59424 0
10329 1
10718 1
18586 1
21561 1
33442 1
71763 1 71763 1
9474 2
10286 2
10433 2
10589 2
73798 2
75161 2 75161 2
86762 2 86762 2
96171 2 96171 2