From b14505db32b653544bb28fa480aa8dc898ed5022 Mon Sep 17 00:00:00 2001 From: Anthony Samms Date: Sun, 21 Sep 2025 02:19:04 -0400 Subject: [PATCH] add combo announcements --- libs/tja.py | 1 + scenes/devtest.py | 6 +++--- scenes/game.py | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/libs/tja.py b/libs/tja.py index c402a91..6a2d2b2 100644 --- a/libs/tja.py +++ b/libs/tja.py @@ -551,6 +551,7 @@ class TJAParser: bar_line.load_ms = bar_line.hit_ms - (self.distance / pixels_per_ms) bar_line.type = 0 bar_line.display = barline_display + bar_line.gogo_time = gogo_time bar_line.bpm = bpm if barline_added: bar_line.display = False diff --git a/scenes/devtest.py b/scenes/devtest.py index aa42aa2..d189758 100644 --- a/scenes/devtest.py +++ b/scenes/devtest.py @@ -2,7 +2,7 @@ import pyray as ray from libs.utils import get_current_ms from libs.texture import tex -from scenes.game import GogoTime, NoteArc +from scenes.game import ComboAnnounce class DevScreen: @@ -16,7 +16,7 @@ class DevScreen: if not self.screen_init: self.screen_init = True tex.load_screen_textures('game') - self.obj = GogoTime() + self.obj = ComboAnnounce(0, get_current_ms()) def on_screen_end(self, next_screen: str): self.screen_init = False @@ -28,7 +28,7 @@ class DevScreen: if ray.is_key_pressed(ray.KeyboardKey.KEY_ENTER): return self.on_screen_end('GAME') elif ray.is_key_pressed(ray.KeyboardKey.KEY_SPACE): - self.obj = GogoTime() + self.obj = ComboAnnounce(100, get_current_ms()) def draw(self): ray.draw_rectangle(0, 0, 1280, 720, ray.GREEN) diff --git a/scenes/game.py b/scenes/game.py index 1534d59..c8c866c 100644 --- a/scenes/game.py +++ b/scenes/game.py @@ -270,6 +270,7 @@ class Player: self.combo_display = Combo(self.combo, 0) self.score_counter = ScoreCounter(self.score) self.gogo_time: Optional[GogoTime] = None + self.combo_announce = ComboAnnounce(self.combo, 0) self.is_gogo_time = self.play_notes[0].gogo_time if self.play_notes else False plate_info = global_data.config['nameplate'] self.nameplate = Nameplate(plate_info['name'], plate_info['title'], global_data.player_num, plate_info['dan'], plate_info['gold']) @@ -401,6 +402,8 @@ class Player: self.combo += 1 if self.combo % 10 == 0: self.chara.set_animation('10_combo') + if self.combo % 100 == 0: + self.combo_announce = ComboAnnounce(self.combo, current_time) if self.combo > self.max_combo: self.max_combo = self.combo @@ -607,6 +610,7 @@ class Player: def update(self, game_screen: GameScreen, current_time: float): self.note_manager(game_screen.current_ms, game_screen.background, current_time) self.combo_display.update(current_time, self.combo) + self.combo_announce.update(current_time) self.drumroll_counter_manager(current_time) self.animation_manager(self.draw_judge_list, current_time) self.balloon_manager(current_time) @@ -806,6 +810,7 @@ class Player: # Group 6: UI overlays self.combo_display.draw() + self.combo_announce.draw() tex.draw_texture('lane', 'lane_score_cover') tex.draw_texture('lane', f'{self.player_number}p_icon') tex.draw_texture('lane', 'lane_difficulty', frame=self.difficulty) @@ -1500,6 +1505,49 @@ class GogoTime: for i in range(5): tex.draw_texture('gogo_time', 'explosion', frame=self.explosion_anim.attribute, index=i) +class ComboAnnounce: + def __init__(self, combo: int, current_time_ms: float): + self.combo = combo + self.wait = current_time_ms + self.fade = Animation.create_fade(100) + self.fade.start() + self.is_finished = False + + def update(self, current_time_ms: float): + if current_time_ms >= self.wait + 1666.67 and not self.is_finished: + self.fade.start() + self.is_finished = True + + self.fade.update(current_time_ms) + + def draw(self): + if self.combo == 0: + return + if not self.is_finished: + fade = 1 - self.fade.attribute + else: + fade = self.fade.attribute + tex.draw_texture('combo', f'announce_bg_{global_data.player_num}p', fade=fade) + + if self.combo >= 1000: + thousands = self.combo // 1000 + remaining_hundreds = (self.combo % 1000) // 100 + thousands_offset = -110 + hundreds_offset = 20 + if self.combo % 1000 == 0: + tex.draw_texture('combo', 'announce_number', frame=thousands-1, x=-23, fade=fade) + tex.draw_texture('combo', 'announce_add', frame=0, x=435, fade=fade) + else: + if thousands <= 5: + tex.draw_texture('combo', 'announce_add', frame=thousands, x=429 + thousands_offset, fade=fade) + if remaining_hundreds > 0: + tex.draw_texture('combo', 'announce_number', frame=remaining_hundreds-1, x=hundreds_offset, fade=fade) + text_offset = -30 + else: + text_offset = 0 + tex.draw_texture('combo', 'announce_number', frame=self.combo // 100 - 1, x=0, fade=fade) + tex.draw_texture('combo', 'announce_text', x=-text_offset/2, fade=fade) + class Gauge: def __init__(self, player_num: str, difficulty: int, level: int, total_notes: int): self.player_num = player_num