refactoring

This commit is contained in:
Yonokid
2025-04-23 19:14:09 -04:00
parent 0012868d4e
commit 3291eccdcd
11 changed files with 634 additions and 482 deletions

View File

@@ -8,16 +8,18 @@ from libs.animation import Animation
from libs.audio import audio
from libs.tja import TJAParser, calculate_base_score
from libs.utils import (
GlobalData,
OutlinedText,
get_config,
get_current_ms,
global_data,
load_all_textures_from_zip,
load_image_from_zip,
load_texture_from_zip,
)
class GameScreen:
def __init__(self, width, height):
def __init__(self, width: int, height: int):
self.width = width
self.height = height
self.judge_x = 414
@@ -25,25 +27,13 @@ class GameScreen:
self.song_is_started = False
def load_textures(self):
self.textures = load_all_textures_from_zip('Graphics\\lumendata\\enso_system\\common.zip')
zip_file = 'Graphics\\lumendata\\enso_system\\common.zip'
self.texture_judge_circle = load_texture_from_zip(zip_file, 'lane_hit_img00017.png')
self.image_lane = load_image_from_zip(zip_file, 'lane_img00000.png')
ray.image_resize(self.image_lane, 948, 176)
self.texture_lane = ray.load_texture_from_image(self.image_lane)
self.texture_lane_cover = load_texture_from_zip(zip_file, 'lane_obi_img00000.png')
self.texture_score_cover = load_texture_from_zip(zip_file, 'lane_obi_img00003.png')
self.texture_don = [load_texture_from_zip(zip_file, 'onp_don_img00000.png'),
load_texture_from_zip(zip_file, 'onp_don_img00001.png')]
self.texture_kat = [load_texture_from_zip(zip_file, 'onp_katsu_img00000.png'),
load_texture_from_zip(zip_file, 'onp_katsu_img00001.png')]
self.texture_dai_don = [load_texture_from_zip(zip_file, 'onp_don_dai_img00000.png'),
load_texture_from_zip(zip_file, 'onp_don_dai_img00001.png')]
self.texture_dai_kat = [load_texture_from_zip(zip_file, 'onp_katsu_dai_img00000.png'),
load_texture_from_zip(zip_file, 'onp_katsu_dai_img00001.png')]
image = load_image_from_zip(zip_file, 'lane_img00000.png')
ray.image_resize(image, 948, 176)
ray.unload_texture(self.textures['lane'][0])
self.textures['lane'][0] = ray.load_texture_from_image(image)
self.texture_balloon_head = [load_texture_from_zip(zip_file, 'onp_fusen_img00001.png'),
load_texture_from_zip(zip_file, 'onp_fusen_img00002.png')]
@@ -62,18 +52,12 @@ class GameScreen:
load_texture_from_zip(zip_file, 'onp_renda_dai_img00000.png')]
self.texture_dai_drumroll_tail = [load_texture_from_zip(zip_file, 'onp_renda_dai_img00001.png'),
load_texture_from_zip(zip_file, 'onp_renda_dai_img00001.png')]
self.texture_drumroll_count = load_texture_from_zip(zip_file, 'renda_num_img00000.png')
self.texture_drumroll_number = []
for i in range(1, 11):
filename = f'renda_num_img{str(i).zfill(5)}.png'
self.texture_drumroll_number.append(load_texture_from_zip(zip_file, filename))
self.texture_barline = load_texture_from_zip(zip_file, 'lane_syousetsu_img00000.png')
self.texture_good = load_texture_from_zip(zip_file, 'lane_hit_effect_img00009.png')
self.texture_good_hit_center = load_texture_from_zip(zip_file, 'lane_hit_img00019.png')
self.texture_good_hit_center_big = load_texture_from_zip(zip_file, 'lane_hit_img00021.png')
self.texture_good_hit_effect = [load_texture_from_zip(zip_file, 'lane_hit_effect_img00005.png'),
load_texture_from_zip(zip_file, 'lane_hit_effect_img00006.png'),
load_texture_from_zip(zip_file, 'lane_hit_effect_img00007.png'),
@@ -99,25 +83,21 @@ class GameScreen:
load_texture_from_zip(zip_file, 'lane_hit_effect_img00019.png'),
load_texture_from_zip(zip_file, 'lane_hit_effect_img00020.png')]
self.texture_bad = load_texture_from_zip(zip_file, 'lane_hit_effect_img00010.png')
self.image_lane_effect_good = load_image_from_zip(zip_file, 'lane_hit_img00007.png')
ray.image_resize(self.image_lane_effect_good, 951, 130)
self.image_lane_effect_don = load_image_from_zip(zip_file, 'lane_hit_img00005.png')
ray.image_resize(self.image_lane_effect_don, 951, 130)
self.image_lane_effect_kat = load_image_from_zip(zip_file, 'lane_hit_img00006.png')
ray.image_resize(self.image_lane_effect_kat, 951, 130)
self.texture_lane_effect_good = ray.load_texture_from_image(self.image_lane_effect_good)
self.texture_lane_effect_don = ray.load_texture_from_image(self.image_lane_effect_don)
self.texture_lane_effect_kat = ray.load_texture_from_image(self.image_lane_effect_kat)
image = load_image_from_zip(zip_file, 'lane_hit_img00005.png')
ray.image_resize(image, 951, 130)
ray.unload_texture(self.textures['lane_hit'][5])
self.textures['lane_hit'][5] = ray.load_texture_from_image(image)
image = load_image_from_zip(zip_file, 'lane_hit_img00006.png')
ray.image_resize(image, 951, 130)
ray.unload_texture(self.textures['lane_hit'][6])
self.textures['lane_hit'][6] = ray.load_texture_from_image(image)
image = load_image_from_zip(zip_file, 'lane_hit_img00007.png')
ray.image_resize(image, 951, 130)
ray.unload_texture(self.textures['lane_hit'][7])
self.textures['lane_hit'][7] = ray.load_texture_from_image(image)
self.texture_drum = load_texture_from_zip(zip_file, 'lane_obi_img00014.png')
self.texture_don_R = load_texture_from_zip(zip_file, 'lane_obi_img00015.png')
self.texture_don_L = load_texture_from_zip(zip_file, 'lane_obi_img00016.png')
self.texture_kat_R = load_texture_from_zip(zip_file, 'lane_obi_img00017.png')
self.texture_kat_L = load_texture_from_zip(zip_file, 'lane_obi_img00018.png')
self.texture_1p_emblem = load_texture_from_zip(zip_file, 'lane_obi_img00019.png')
self.texture_difficulty = [load_texture_from_zip(zip_file, 'lane_obi_img00021.png'),
load_texture_from_zip(zip_file, 'lane_obi_img00022.png'),
load_texture_from_zip(zip_file, 'lane_obi_img00023.png'),
@@ -147,30 +127,8 @@ class GameScreen:
filename = 'onp_renda_moji_img00001.png'
self.texture_se_moji.append(load_texture_from_zip(zip_file, filename))
zip_file = 'Graphics\\lumendata\\enso_system\\base1p.zip'
self.texture_balloon_speech_bubble_p1 = load_texture_from_zip(zip_file, 'action_fusen_1p_img00000.png')
self.texture_balloon = [load_texture_from_zip(zip_file, 'action_fusen_1p_img00011.png'),
load_texture_from_zip(zip_file, 'action_fusen_1p_img00012.png'),
load_texture_from_zip(zip_file, 'action_fusen_1p_img00013.png'),
load_texture_from_zip(zip_file, 'action_fusen_1p_img00014.png'),
load_texture_from_zip(zip_file, 'action_fusen_1p_img00015.png'),
load_texture_from_zip(zip_file, 'action_fusen_1p_img00016.png'),
load_texture_from_zip(zip_file, 'action_fusen_1p_img00017.png'),
load_texture_from_zip(zip_file, 'action_fusen_1p_img00018.png')]
self.texture_balloon_number = [load_texture_from_zip(zip_file, 'action_fusen_1p_img00001.png'),
load_texture_from_zip(zip_file, 'action_fusen_1p_img00002.png'),
load_texture_from_zip(zip_file, 'action_fusen_1p_img00003.png'),
load_texture_from_zip(zip_file, 'action_fusen_1p_img00004.png'),
load_texture_from_zip(zip_file, 'action_fusen_1p_img00005.png'),
load_texture_from_zip(zip_file, 'action_fusen_1p_img00006.png'),
load_texture_from_zip(zip_file, 'action_fusen_1p_img00007.png'),
load_texture_from_zip(zip_file, 'action_fusen_1p_img00008.png'),
load_texture_from_zip(zip_file, 'action_fusen_1p_img00009.png'),
load_texture_from_zip(zip_file, 'action_fusen_1p_img00010.png')]
self.texture_base_score_numbers = []
for i in range(0, 10):
filename = f'score_add_1p_img{str(i).zfill(5)}.png'
self.texture_base_score_numbers.append(load_texture_from_zip(zip_file, filename))
self.textures.update(load_all_textures_from_zip('Graphics\\lumendata\\enso_system\\base1p.zip'))
self.textures.update(load_all_textures_from_zip('Graphics\\lumendata\\enso_system\\don1p.zip'))
def load_sounds(self):
self.sound_don = audio.load_sound('Sounds\\inst_00_don.wav')
@@ -182,10 +140,10 @@ class GameScreen:
self.load_sounds()
#Map notes to textures
self.note_type_dict = {'1': self.texture_don,
'2': self.texture_kat,
'3': self.texture_dai_don,
'4': self.texture_dai_kat,
self.note_type_dict = {'1': self.textures['onp_don'],
'2': self.textures['onp_katsu'],
'3': self.textures['onp_don_dai'],
'4': self.textures['onp_katsu_dai'],
'5': self.texture_drumroll_head,
'6': self.texture_dai_drumroll_head,
'7': self.texture_balloon_head,
@@ -207,14 +165,16 @@ class GameScreen:
def update(self):
if GlobalData.start_song and not self.song_is_started:
self.init_tja(GlobalData.selected_song, GlobalData.selected_difficulty)
if global_data.start_song and not self.song_is_started:
self.init_tja(global_data.selected_song, global_data.selected_difficulty)
self.song_is_started = True
self.current_ms = get_current_ms() - self.start_ms
self.player_1.update(self)
if len(self.player_1.play_note_list) == 0 and not audio.is_sound_playing(self.song_music):
GlobalData.result_good, GlobalData.result_ok, GlobalData.result_bad, GlobalData.result_score = self.player_1.get_result_score()
GlobalData.start_song = False
global_data.result_good, global_data.result_ok, global_data.result_bad, global_data.result_score = self.player_1.get_result_score()
global_data.start_song = False
self.song_is_started = False
return 'RESULT'
@@ -222,7 +182,7 @@ class GameScreen:
self.player_1.draw(self)
class Player:
def __init__(self, game_screen, player_number: int, difficulty: int, judge_offset: int):
def __init__(self, game_screen: GameScreen, player_number: int, difficulty: int, judge_offset: int):
self.timing_good = 25.0250015258789
self.timing_ok = 75.0750045776367
self.timing_bad = 108.441665649414
@@ -258,38 +218,42 @@ class Player:
self.arc_points = 25
self.draw_judge_list = []
self.draw_effect_list = []
self.draw_arc_list = []
self.draw_drum_hit_list = []
self.drumroll_counter = []
self.balloon_list = []
self.combo_list = []
self.score_list = []
self.base_score_list = []
self.draw_judge_list: list[Judgement] = []
self.draw_effect_list: list[LaneHitEffect] = []
self.draw_arc_list: list[NoteArc] = []
self.draw_drum_hit_list: list[DrumHitEffect] = []
self.drumroll_counter: list[DrumrollCounter] = []
self.balloon_list: list[BalloonAnimation] = []
self.base_score_list: list[ScoreCounterAnimation] = []
self.combo_display = Combo(self.combo, game_screen.current_ms)
self.score_counter = ScoreCounter(self.score, game_screen.current_ms)
self.song_info = SongInfo(game_screen.current_ms, game_screen.tja.title, 'TEST')
self.input_log: dict[float, str] = dict()
def get_result_score(self):
return self.good_count, self.ok_count, self.bad_count, self.score
def get_position(self, game_screen, ms, pixels_per_frame):
def get_position(self, game_screen: GameScreen, ms: float, pixels_per_frame: float):
return int(game_screen.width + pixels_per_frame * 60 / 1000 * (ms - game_screen.current_ms + self.judge_offset) - 64)
def animation_manager(self, game_screen, animation_list):
def animation_manager(self, game_screen: GameScreen, animation_list: list):
if len(animation_list) <= 0:
return
for i in range(len(animation_list)-1, -1, -1):
animation = animation_list[i]
animation.update(game_screen.current_ms)
if animation.is_finished:
animation_list.pop(i)
def bar_manager(self, game_screen):
def bar_manager(self, game_screen: GameScreen):
#Add bar to current_bars list if it is ready to be shown on screen
if len(self.draw_bar_list) > 0 and game_screen.current_ms > self.draw_bar_list[0]['load_ms']:
self.current_bars.append(self.draw_bar_list.popleft())
#If a bar is off screen, remove it
if len(self.current_bars) <= 0:
if len(self.current_bars) == 0:
return
for i in range(len(self.current_bars)-1, -1, -1):
@@ -298,12 +262,12 @@ class Player:
if position < game_screen.judge_x + 650:
self.current_bars.pop(i)
def play_note_manager(self, game_screen):
def play_note_manager(self, game_screen: GameScreen):
#Add note to current_notes list if it is ready to be shown on screen
if len(self.play_note_list) > 0 and game_screen.current_ms + 1000 >= self.play_note_list[0]['load_ms']:
if self.play_note_list[0]['note'] == '8':
self.current_notes.append(self.play_note_list.popleft())
self.current_notes.append(self.play_note_list.popleft())
if len(self.play_note_list) > 0 and self.play_note_list[0]['note'] == '8':
self.current_notes.append(self.play_note_list.popleft())
#if a note was not hit within the window, remove it
if len(self.current_notes) == 0:
@@ -328,7 +292,7 @@ class Player:
self.is_drumroll = False
self.is_balloon = False
def draw_note_manager(self, game_screen):
def draw_note_manager(self, game_screen: GameScreen):
if len(self.draw_note_list) > 0 and game_screen.current_ms + 1000 >= self.draw_note_list[0]['load_ms']:
if self.draw_note_list[0]['note'] in {'5', '6', '7'}:
while self.draw_note_list[0]['note'] != '8':
@@ -345,7 +309,7 @@ class Player:
self.current_notes_draw[0]['color'] += 1
note = self.current_notes_draw[0]
if note['note'] in {'5', '6', '7'}:
if note['note'] in {'5', '6', '7'} and len(self.current_notes_draw) > 1:
note = self.current_notes_draw[1]
position = self.get_position(game_screen, note['ms'], note['ppf'])
if position < game_screen.judge_x + 650:
@@ -353,12 +317,12 @@ class Player:
self.current_notes_draw.pop(0)
self.current_notes_draw.pop(0)
def note_manager(self, game_screen):
def note_manager(self, game_screen: GameScreen):
self.bar_manager(game_screen)
self.play_note_manager(game_screen)
self.draw_note_manager(game_screen)
def note_correct(self, game_screen, note):
def note_correct(self, game_screen: GameScreen, note: dict):
index = note['index']
if note['note'] == '8':
note_type = game_screen.note_type_dict['3']
@@ -376,19 +340,16 @@ class Player:
index = self.current_notes_draw.index(note)
self.current_notes_draw.pop(index)
def check_drumroll(self, game_screen, drum_type):
def check_drumroll(self, game_screen: GameScreen, drum_type: str):
note_type = game_screen.note_type_dict[str(int(drum_type)+self.drumroll_big)]
self.draw_arc_list.append(NoteArc(note_type, game_screen.current_ms, self.player_number))
self.curr_drumroll_count += 1
self.score += 100
self.base_score_list.append(ScoreCounterAnimation(game_screen.current_ms, 100))
color = 255 - (self.curr_drumroll_count*10)
if color < 0:
self.current_notes_draw[0]['color'] = 0
else:
self.current_notes_draw[0]['color'] = color
color = max(0, 255 - (self.curr_drumroll_count * 10))
self.current_notes_draw[0]['color'] = color
def check_balloon(self, game_screen, drum_type):
def check_balloon(self, game_screen: GameScreen, drum_type: str):
current_note = self.current_notes[0]
if current_note['note'] == '7':
current_note = self.current_notes[1]
@@ -403,8 +364,10 @@ class Player:
self.current_notes_draw[0]['popped'] = True
audio.play_sound(game_screen.sound_balloon_pop)
self.note_correct(game_screen, self.current_notes[0])
if len(self.current_notes) > 1 and self.current_notes[0]['note'] == '8':
self.note_correct(game_screen, self.current_notes[0])
def check_note(self, game_screen, drum_type):
def check_note(self, game_screen: GameScreen, drum_type: str):
if self.is_drumroll:
self.check_drumroll(game_screen, drum_type)
elif self.is_balloon and drum_type == '1':
@@ -412,12 +375,12 @@ class Player:
elif len(self.current_notes) != 0:
self.curr_drumroll_count = 0
self.curr_balloon_count = 0
current_note = self.current_notes[0]
#Fix later
i = 0
while current_note['note'] in {'5', '6', '7', '8'}:
i += 1
current_note = self.current_notes[i]
current_note = next(
(note for note in self.current_notes if note['note'] not in {'5', '6', '7', '8'}),
None # Default if no matching note is found
)
if current_note is None:
return
note_type = current_note['note']
note_ms = current_note['ms']
#If the wrong key was hit, stop checking
@@ -454,7 +417,7 @@ class Player:
self.combo = 0
self.current_notes.popleft()
def drumroll_counter_manager(self, game_screen):
def drumroll_counter_manager(self, game_screen: GameScreen):
if self.is_drumroll and self.curr_drumroll_count > 0:
if len(self.drumroll_counter) == 0 or self.drumroll_counter[-1].is_finished:
self.drumroll_counter.append(DrumrollCounter(game_screen.current_ms))
@@ -467,7 +430,7 @@ class Player:
else:
self.drumroll_counter[0].update(game_screen, game_screen.current_ms, self.curr_drumroll_count)
def balloon_animation_manager(self, game_screen):
def balloon_animation_manager(self, game_screen: GameScreen):
if len(self.balloon_list) <= 0:
return
@@ -479,49 +442,43 @@ class Player:
else:
self.balloon_list[0].update(game_screen, game_screen.current_ms, self.curr_balloon_count, True)
def combo_manager(self, game_screen):
if self.combo >= 3 and len(self.combo_list) == 0:
self.combo_list.append(Combo(self.combo, game_screen.current_ms))
elif self.combo < 3 and len(self.combo_list) != 0:
self.combo_list.pop(0)
elif len(self.combo_list) == 1:
self.combo_list[0].update(game_screen, game_screen.current_ms, self.combo)
def key_manager(self, game_screen: GameScreen):
left_kats = get_config()["keybinds"]["left_kat"]
left_dons = get_config()["keybinds"]["left_don"]
right_dons = get_config()["keybinds"]["right_don"]
right_kats = get_config()["keybinds"]["right_kat"]
for left_don in left_dons:
if ray.is_key_pressed(ord(left_don)):
self.draw_effect_list.append(LaneHitEffect(game_screen.current_ms, 'DON'))
self.draw_drum_hit_list.append(DrumHitEffect(game_screen.current_ms, 'DON', 'L'))
audio.play_sound(game_screen.sound_don)
self.check_note(game_screen, '1')
self.input_log[game_screen.current_ms] = 'DON'
for right_don in right_dons:
if ray.is_key_pressed(ord(right_don)):
self.draw_effect_list.append(LaneHitEffect(game_screen.current_ms, 'DON'))
self.draw_drum_hit_list.append(DrumHitEffect(game_screen.current_ms, 'DON', 'R'))
audio.play_sound(game_screen.sound_don)
self.check_note(game_screen, '1')
self.input_log[game_screen.current_ms] = 'DON'
for left_kat in left_kats:
if ray.is_key_pressed(ord(left_kat)):
self.draw_effect_list.append(LaneHitEffect(game_screen.current_ms, 'KAT'))
self.draw_drum_hit_list.append(DrumHitEffect(game_screen.current_ms, 'KAT', 'L'))
audio.play_sound(game_screen.sound_kat)
self.check_note(game_screen, '2')
self.input_log[game_screen.current_ms] = 'KAT'
for right_kat in right_kats:
if ray.is_key_pressed(ord(right_kat)):
self.draw_effect_list.append(LaneHitEffect(game_screen.current_ms, 'KAT'))
self.draw_drum_hit_list.append(DrumHitEffect(game_screen.current_ms, 'KAT', 'R'))
audio.play_sound(game_screen.sound_kat)
self.check_note(game_screen, '2')
self.input_log[game_screen.current_ms] = 'KAT'
def score_manager(self, game_screen):
if len(self.score_list) == 0:
self.score_list.append(ScoreCounter(self.score, game_screen.current_ms))
elif len(self.score_list) == 1:
self.score_list[0].update(game_screen.current_ms, self.score)
def key_manager(self, game_screen):
left_kat = ord(get_config()["keybinds"]["left_kat"])
left_don = ord(get_config()["keybinds"]["left_don"])
right_don = ord(get_config()["keybinds"]["right_don"])
right_kat = ord(get_config()["keybinds"]["right_kat"])
if ray.is_key_pressed(left_don):
self.draw_effect_list.append(LaneHitEffect(game_screen.current_ms, 'DON'))
self.draw_drum_hit_list.append(DrumHitEffect(game_screen.current_ms, 'DON', 'L'))
audio.play_sound(game_screen.sound_don)
self.check_note(game_screen, '1')
if ray.is_key_pressed(right_don):
self.draw_effect_list.append(LaneHitEffect(game_screen.current_ms, 'DON'))
self.draw_drum_hit_list.append(DrumHitEffect(game_screen.current_ms, 'DON', 'R'))
audio.play_sound(game_screen.sound_don)
self.check_note(game_screen, '1')
if ray.is_key_pressed(left_kat):
self.draw_effect_list.append(LaneHitEffect(game_screen.current_ms, 'KAT'))
self.draw_drum_hit_list.append(DrumHitEffect(game_screen.current_ms, 'KAT', 'L'))
audio.play_sound(game_screen.sound_kat)
self.check_note(game_screen, '2')
if ray.is_key_pressed(right_kat):
self.draw_effect_list.append(LaneHitEffect(game_screen.current_ms, 'KAT'))
self.draw_drum_hit_list.append(DrumHitEffect(game_screen.current_ms, 'KAT', 'R'))
audio.play_sound(game_screen.sound_kat)
self.check_note(game_screen, '2')
def update(self, game_screen):
def update(self, game_screen: GameScreen):
self.note_manager(game_screen)
self.combo_manager(game_screen)
self.combo_display.update(game_screen, game_screen.current_ms, self.combo)
self.drumroll_counter_manager(game_screen)
self.balloon_animation_manager(game_screen)
self.animation_manager(game_screen, self.draw_judge_list)
@@ -529,20 +486,20 @@ class Player:
self.animation_manager(game_screen, self.draw_drum_hit_list)
self.animation_manager(game_screen, self.draw_arc_list)
self.animation_manager(game_screen, self.base_score_list)
self.score_manager(game_screen)
self.song_info.update(game_screen.current_ms)
self.score_counter.update(game_screen.current_ms, self.score)
self.key_manager(game_screen)
def draw_animation_list(self, game_screen, animation_list):
def draw_animation_list(self, game_screen: GameScreen, animation_list: list):
for animation in animation_list:
animation.draw(game_screen)
def draw_drumroll(self, game_screen, big, position, index, color):
def draw_drumroll(self, game_screen: GameScreen, big: bool, position: int, index: int, color: int):
drumroll_start_position = position
tail = self.current_notes_draw[index+1]
i = 0
while tail['note'] != '8':
i = 1
while self.current_notes_draw[index+i]['note'] != '8':
i += 1
tail = self.current_notes_draw[index+i]
tail = self.current_notes_draw[index+i]
if big:
drumroll_body = 'dai_drumroll_body'
drumroll_tail = 'dai_drumroll_tail'
@@ -554,14 +511,13 @@ class Player:
self.draw_note(game_screen, drumroll_body, (drumroll_start_position+64), color, 8, drumroll_length=length)
self.draw_note(game_screen, drumroll_tail, drumroll_end_position, color, 10, drumroll_length=None)
def draw_balloon(self, game_screen, note, position, index):
def draw_balloon(self, game_screen: GameScreen, note: dict, position: int, index: int):
if self.current_notes_draw[0].get('popped', None):
return
end_time = self.current_notes_draw[index+1]
i = 0
while end_time['note'] != '8':
i = 1
while self.current_notes_draw[index+i]['note'] != '8':
i += 1
end_time = self.current_notes_draw[index+i]
end_time = self.current_notes_draw[index+i]
end_time_position = self.get_position(game_screen, end_time['load_ms'], end_time['ppf'])
if game_screen.current_ms >= end_time['ms']:
position = end_time_position
@@ -569,11 +525,11 @@ class Player:
position = 349
self.draw_note(game_screen, '7', position, 255, 9)
def draw_note(self, game_screen, note, position, color, se_note, drumroll_length=None):
def draw_note(self, game_screen: GameScreen, note: str, position: int, color: int, se_note: int | None, drumroll_length: int | None=None):
note_padding = 64
if note == 'barline':
y = 184
ray.draw_texture(game_screen.texture_barline, position+note_padding-4, y+6, ray.WHITE)
ray.draw_texture(game_screen.textures['lane_syousetsu'][0], position+note_padding-4, y+6, ray.WHITE)
return
if note not in game_screen.note_type_dict:
return
@@ -610,7 +566,7 @@ class Player:
dest_rect = ray.Rectangle(position-offset - (game_screen.texture_se_moji[se_note].width // 2) + 64, 323, drumroll_length,game_screen.texture_se_moji[se_note].height)
ray.draw_texture_pro(game_screen.texture_se_moji[se_note], source_rect, dest_rect, ray.Vector2(0,0), 0, ray.WHITE)
def draw_bars(self, game_screen):
def draw_bars(self, game_screen: GameScreen):
if len(self.current_bars) <= 0:
return
@@ -620,7 +576,7 @@ class Player:
position = self.get_position(game_screen, load_ms, pixels_per_frame)
self.draw_note(game_screen, 'barline', position, 255, None)
def draw_notes(self, game_screen):
def draw_notes(self, game_screen: GameScreen):
if len(self.current_notes_draw) <= 0:
return
@@ -640,28 +596,37 @@ class Player:
self.draw_note(game_screen, note_type, position, 255, note['se_note'])
#ray.draw_text(str(i), position+64, 192, 25, ray.GREEN)
def draw(self, game_screen):
ray.draw_texture(game_screen.texture_lane, 332, 184, ray.WHITE)
def draw_gauge(self, game_screen: GameScreen):
ray.draw_texture(game_screen.textures['gage_don_1p_hard'][0], 327, 128, ray.WHITE)
ray.draw_texture(game_screen.textures['gage_don_1p_hard'][1], 483, 124, ray.WHITE)
ray.draw_texture(game_screen.textures['gage_don_1p_hard'][10], 483, 124, ray.fade(ray.WHITE, 0.15))
ray.draw_texture(game_screen.textures['gage_don_1p_hard'][11], 1038, 141, ray.WHITE)
ray.draw_texture(game_screen.textures['gage_don_1p_hard'][12], 1187, 130, ray.WHITE)
def draw(self, game_screen: GameScreen):
ray.draw_texture(game_screen.textures['lane'][0], 332, 184, ray.WHITE)
self.draw_gauge(game_screen)
self.draw_animation_list(game_screen, self.draw_effect_list)
ray.draw_texture(game_screen.texture_judge_circle, 342, 184, ray.WHITE)
ray.draw_texture(game_screen.textures['lane_hit'][17], 342, 184, ray.WHITE)
self.draw_animation_list(game_screen, self.draw_judge_list)
self.draw_bars(game_screen)
self.draw_notes(game_screen)
ray.draw_texture(game_screen.texture_lane_cover, 0, 184, ray.WHITE)
ray.draw_texture(game_screen.textures['lane_obi'][0], 0, 184, ray.WHITE)
ray.draw_texture(game_screen.texture_drum, 211, 206, ray.WHITE)
self.draw_animation_list(game_screen, self.draw_drum_hit_list)
self.draw_animation_list(game_screen, self.combo_list)
ray.draw_texture(game_screen.texture_score_cover, 0, 184, ray.WHITE)
ray.draw_texture(game_screen.texture_1p_emblem, 0, 225, ray.WHITE)
self.combo_display.draw(game_screen)
ray.draw_texture(game_screen.textures['lane_obi'][3], 0, 184, ray.WHITE)
ray.draw_texture(game_screen.textures['lane_obi'][19], 0, 225, ray.WHITE)
ray.draw_texture(game_screen.texture_difficulty[self.difficulty], 50, 222, ray.WHITE)
self.song_info.draw(game_screen)
self.draw_animation_list(game_screen, self.drumroll_counter)
self.draw_animation_list(game_screen, self.draw_arc_list)
self.draw_animation_list(game_screen, self.balloon_list)
self.draw_animation_list(game_screen, self.score_list)
self.score_counter.draw(game_screen)
self.draw_animation_list(game_screen, self.base_score_list)
class Judgement:
def __init__(self, current_ms, type, big):
def __init__(self, current_ms: float, type: str, big: bool):
self.type = type
self.big = big
self.is_finished = False
@@ -680,7 +645,7 @@ class Judgement:
self.texture_animation = Animation(current_ms, 100, 'texture_change')
self.texture_animation.params['textures'] = [(33, 50, 1), (50, 83, 2), (83, 100, 3), (100, float('inf'), 4)]
def update(self, current_ms):
def update(self, current_ms: float):
self.fade_animation_1.update(current_ms)
self.fade_animation_2.update(current_ms)
self.move_animation.update(current_ms)
@@ -689,17 +654,17 @@ class Judgement:
if self.fade_animation_2.is_finished:
self.is_finished = True
def draw(self, game_screen):
def draw(self, game_screen: GameScreen):
y = self.move_animation.attribute
index = self.texture_animation.attribute
index = int(self.texture_animation.attribute)
hit_color = ray.fade(ray.WHITE, self.fade_animation_1.attribute)
color = ray.fade(ray.WHITE, self.fade_animation_2.attribute)
if self.type == 'GOOD':
if self.big:
ray.draw_texture(game_screen.texture_good_hit_center_big, 342, 184, color)
ray.draw_texture(game_screen.textures['lane_hit'][21], 342, 184, color)
ray.draw_texture(game_screen.texture_good_hit_effect_big[index], 304, 143, hit_color)
else:
ray.draw_texture(game_screen.texture_good_hit_center, 342, 184, color)
ray.draw_texture(game_screen.textures['lane_hit'][19], 342, 184, color)
ray.draw_texture(game_screen.texture_good_hit_effect[index], 304, 143, hit_color)
ray.draw_texture(game_screen.texture_good, 370, int(y), color)
elif self.type == 'OK':
@@ -711,10 +676,10 @@ class Judgement:
ray.draw_texture(game_screen.texture_ok_hit_effect[index], 304, 143, hit_color)
ray.draw_texture(game_screen.texture_ok, 370, int(y), color)
elif self.type == 'BAD':
ray.draw_texture(game_screen.texture_bad, 370, int(y), color)
ray.draw_texture(game_screen.textures['lane_hit_effect'][10], 370, int(y), color)
class LaneHitEffect:
def __init__(self, current_ms, type):
def __init__(self, current_ms: float, type: str):
self.type = type
self.color = ray.fade(ray.WHITE, 0.5)
self.animation = Animation(current_ms, 150, 'fade')
@@ -722,23 +687,23 @@ class LaneHitEffect:
self.animation.params['initial_opacity'] = 0.5
self.is_finished = False
def update(self, current_ms):
def update(self, current_ms: float):
self.animation.update(current_ms)
fade_opacity = self.animation.attribute
self.color = ray.fade(ray.WHITE, fade_opacity)
if self.animation.is_finished:
self.is_finished = True
def draw(self, game_screen):
def draw(self, game_screen: GameScreen):
if self.type == 'GOOD':
ray.draw_texture(game_screen.texture_lane_effect_good, 328, 192, self.color)
ray.draw_texture(game_screen.textures['lane_hit'][7], 328, 192, self.color)
elif self.type == 'DON':
ray.draw_texture(game_screen.texture_lane_effect_don, 328, 192, self.color)
ray.draw_texture(game_screen.textures['lane_hit'][5], 328, 192, self.color)
elif self.type == 'KAT':
ray.draw_texture(game_screen.texture_lane_effect_kat, 328, 192, self.color)
ray.draw_texture(game_screen.textures['lane_hit'][6], 328, 192, self.color)
class DrumHitEffect:
def __init__(self, current_ms, type, side):
def __init__(self, current_ms: float, type: str, side: str):
self.type = type
self.side = side
self.color = ray.fade(ray.WHITE, 1)
@@ -746,7 +711,7 @@ class DrumHitEffect:
self.animation = Animation(current_ms, 100, 'fade')
self.animation.params['delay'] = 67
def update(self, current_ms):
def update(self, current_ms: float):
self.animation.update(current_ms)
fade_opacity = self.animation.attribute
self.color = ray.fade(ray.WHITE, fade_opacity)
@@ -757,17 +722,17 @@ class DrumHitEffect:
x, y = 211, 206
if self.type == 'DON':
if self.side == 'L':
ray.draw_texture(game_screen.texture_don_L, x, y, self.color)
ray.draw_texture(game_screen.textures['lane_obi'][16], x, y, self.color)
elif self.side == 'R':
ray.draw_texture(game_screen.texture_don_R, x, y, self.color)
ray.draw_texture(game_screen.textures['lane_obi'][15], x, y, self.color)
elif self.type == 'KAT':
if self.side == 'L':
ray.draw_texture(game_screen.texture_kat_L, x, y, self.color)
ray.draw_texture(game_screen.textures['lane_obi'][18], x, y, self.color)
elif self.side == 'R':
ray.draw_texture(game_screen.texture_kat_R, x, y, self.color)
ray.draw_texture(game_screen.textures['lane_obi'][17], x, y, self.color)
class NoteArc:
def __init__(self, note_type, current_ms, player_number):
def __init__(self, note_type: list, current_ms: float, player_number: int):
self.note_type = note_type
self.arc_points = 25
self.create_ms = current_ms
@@ -776,7 +741,7 @@ class NoteArc:
self.y_i = 168
self.is_finished = False
def update(self, current_ms):
def update(self, current_ms: float):
if self.x_i >= 1150:
self.is_finished = True
radius = 414
@@ -808,7 +773,7 @@ class NoteArc:
ray.draw_texture(self.note_type[current_eighth % 2], int(self.x_i), int(self.y_i), ray.WHITE)
class DrumrollCounter:
def __init__(self, current_ms):
def __init__(self, current_ms: float):
self.create_ms = current_ms
self.is_finished = False
self.total_duration = 1349
@@ -817,13 +782,13 @@ class DrumrollCounter:
self.fade_animation.params['delay'] = self.total_duration - 166
self.stretch_animation = Animation(current_ms, 0, 'text_stretch')
def update_count(self, current_ms, count, elapsed_time):
def update_count(self, current_ms: float, count: int, elapsed_time: float):
self.total_duration = elapsed_time + 1349
if self.drumroll_count != count:
self.drumroll_count = count
self.stretch_animation = Animation(current_ms, 50, 'text_stretch')
def update(self, game_screen, current_ms, drumroll_count):
def update(self, game_screen: GameScreen, current_ms: float, drumroll_count: int):
self.stretch_animation.update(current_ms)
self.fade_animation.update(current_ms)
@@ -833,19 +798,19 @@ class DrumrollCounter:
if self.fade_animation.is_finished:
self.is_finished = True
def draw(self, game_screen):
def draw(self, game_screen: GameScreen):
color = ray.fade(ray.WHITE, self.fade_animation.attribute)
ray.draw_texture(game_screen.texture_drumroll_count, 200, 0, color)
ray.draw_texture(game_screen.textures['renda_num'][0], 200, 0, color)
counter = str(self.drumroll_count)
total_width = len(counter) * 52
start_x = 344 - (total_width // 2)
source_rect = ray.Rectangle(0, 0, game_screen.texture_drumroll_number[0].width, game_screen.texture_drumroll_number[0].height)
for i in range(len(counter)):
dest_rect = ray.Rectangle(start_x + (i * 52), 50 - self.stretch_animation.attribute, game_screen.texture_drumroll_number[0].width, game_screen.texture_drumroll_number[0].height + self.stretch_animation.attribute)
ray.draw_texture_pro(game_screen.texture_balloon_number[int(counter[i])], source_rect, dest_rect, ray.Vector2(0,0), 0, color)
ray.draw_texture_pro(game_screen.textures['action_fusen_1p'][int(counter[i])+1], source_rect, dest_rect, ray.Vector2(0,0), 0, color)
class BalloonAnimation:
def __init__(self, current_ms, balloon_total):
def __init__(self, current_ms: float, balloon_total: int):
self.create_ms = current_ms
self.is_finished = False
self.total_duration = 83.33
@@ -856,12 +821,12 @@ class BalloonAnimation:
self.fade_animation = Animation(current_ms, 166, 'fade')
self.stretch_animation = Animation(current_ms, 0, 'text_stretch')
def update_count(self, current_ms, balloon_count):
def update_count(self, current_ms: float, balloon_count: int):
if self.balloon_count != balloon_count:
self.balloon_count = balloon_count
self.stretch_animation = Animation(current_ms, 50, 'text_stretch')
def update(self, game_screen, current_ms, balloon_count, is_popped):
def update(self, game_screen: GameScreen, current_ms: float, balloon_count: int, is_popped: bool):
self.update_count(current_ms, balloon_count)
self.stretch_animation.update(current_ms)
self.is_popped = is_popped
@@ -876,26 +841,26 @@ class BalloonAnimation:
if self.fade_animation.is_finished:
self.is_finished = True
def draw(self, game_screen):
def draw(self, game_screen: GameScreen):
if self.is_popped:
ray.draw_texture(game_screen.texture_balloon[7], 460, 130, self.color)
ray.draw_texture(game_screen.textures['action_fusen_1p'][18], 460, 130, self.color)
elif self.balloon_count >= 1:
balloon_index = (self.balloon_count - 1) * 7 // self.balloon_total
ray.draw_texture(game_screen.texture_balloon[balloon_index], 460, 130, self.color)
balloon_index = (self.balloon_count - 1) * 7 // self.balloon_total + 11
ray.draw_texture(game_screen.textures['action_fusen_1p'][balloon_index], 460, 130, self.color)
if self.balloon_count > 0:
ray.draw_texture(game_screen.texture_balloon_speech_bubble_p1, 414, 40, ray.WHITE)
ray.draw_texture(game_screen.textures['action_fusen_1p'][0], 414, 40, ray.WHITE)
counter = str(self.balloon_total - self.balloon_count + 1)
x, y = 493, 68
margin = 52
total_width = len(counter) * margin
start_x = x - (total_width // 2)
source_rect = ray.Rectangle(0, 0, game_screen.texture_balloon_number[0].width, game_screen.texture_balloon_number[0].height)
source_rect = ray.Rectangle(0, 0, game_screen.textures['action_fusen_1p'][1].width, game_screen.textures['action_fusen_1p'][1].height)
for i in range(len(counter)):
dest_rect = ray.Rectangle(start_x + (i * margin), y - self.stretch_animation.attribute, game_screen.texture_balloon_number[0].width, game_screen.texture_balloon_number[0].height + self.stretch_animation.attribute)
ray.draw_texture_pro(game_screen.texture_balloon_number[int(counter[i])], source_rect, dest_rect, ray.Vector2(0,0), 0, self.color)
dest_rect = ray.Rectangle(start_x + (i * margin), y - self.stretch_animation.attribute, game_screen.textures['action_fusen_1p'][1].width, game_screen.textures['action_fusen_1p'][1].height + self.stretch_animation.attribute)
ray.draw_texture_pro(game_screen.textures['action_fusen_1p'][int(counter[i])+1], source_rect, dest_rect, ray.Vector2(0,0), 0, self.color)
class Combo:
def __init__(self, combo, current_ms):
def __init__(self, combo: int, current_ms: float):
self.combo = combo
self.stretch_animation = Animation(current_ms, 0, 'text_stretch')
self.color = [ray.fade(ray.WHITE, 1), ray.fade(ray.WHITE, 1), ray.fade(ray.WHITE, 1)]
@@ -908,12 +873,12 @@ class Combo:
current_ms + (4 / 3) * self.cycle_time
]
def update_count(self, current_ms, combo):
def update_count(self, current_ms: float, combo: int):
if self.combo != combo:
self.combo = combo
self.stretch_animation = Animation(current_ms, 50, 'text_stretch')
def update(self, game_screen, current_ms, combo):
def update(self, game_screen: GameScreen, current_ms: float, combo: int):
self.update_count(current_ms, combo)
self.stretch_animation.update(current_ms)
@@ -935,7 +900,9 @@ class Combo:
fade = 0
self.color[i] = ray.fade(ray.WHITE, fade)
def draw(self, game_screen):
def draw(self, game_screen: GameScreen):
if self.combo < 3:
return
if self.combo < 100:
text_color = 0
margin = 30
@@ -958,21 +925,22 @@ class Combo:
ray.draw_texture(game_screen.texture_combo_glimmer, x + (i * 30), y + self.glimmer_dict[j], self.color[j])
class ScoreCounter:
def __init__(self, score, current_ms):
def __init__(self, score: int, current_ms: float):
self.score = score
self.create_ms = current_ms
self.stretch_animation = Animation(current_ms, 0, 'text_stretch')
def update_count(self, current_ms, score):
def update_count(self, current_ms: float, score: int):
if self.score != score:
self.score = score
self.stretch_animation = Animation(current_ms, 50, 'text_stretch')
def update(self, current_ms, score):
def update(self, current_ms: float, score: int):
self.update_count(current_ms, score)
self.stretch_animation.update(current_ms)
if self.score > 0:
self.stretch_animation.update(current_ms)
def draw(self, game_screen):
def draw(self, game_screen: GameScreen):
counter = str(self.score)
x, y = 150, 185
margin = 20
@@ -984,8 +952,8 @@ class ScoreCounter:
ray.draw_texture_pro(game_screen.texture_score_numbers[int(counter[i])], source_rect, dest_rect, ray.Vector2(0,0), 0, ray.WHITE)
class ScoreCounterAnimation:
def __init__(self, current_ms, counter):
self.counter = int(counter)
def __init__(self, current_ms: float, counter: int):
self.counter = counter
self.fade_animation_1 = Animation(current_ms, 50, 'fade')
self.fade_animation_1.params['initial_opacity'] = 0.0
self.fade_animation_1.params['final_opacity'] = 1.0
@@ -1016,7 +984,7 @@ class ScoreCounterAnimation:
self.is_finished = False
self.y_pos_list = []
def update(self, current_ms):
def update(self, current_ms: float):
self.fade_animation_1.update(current_ms)
self.move_animation_1.update(current_ms)
self.move_animation_2.update(current_ms)
@@ -1034,7 +1002,7 @@ class ScoreCounterAnimation:
for i in range(1, len(str(self.counter))+1):
self.y_pos_list.append(self.move_animation_4.attribute + i*5)
def draw(self, game_screen):
def draw(self, game_screen: GameScreen):
if self.move_animation_1.is_finished:
x = self.move_animation_2.attribute
else:
@@ -1045,7 +1013,7 @@ class ScoreCounterAnimation:
margin = 20
total_width = len(counter) * margin
start_x = x - total_width
source_rect = ray.Rectangle(0, 0, game_screen.texture_base_score_numbers[0].width, game_screen.texture_base_score_numbers[0].height)
source_rect = ray.Rectangle(0, 0, game_screen.textures['score_add_1p'][0].width, game_screen.textures['score_add_1p'][0].height)
for i in range(len(counter)):
if self.move_animation_3.is_finished:
y = self.y_pos_list[i]
@@ -1053,5 +1021,44 @@ class ScoreCounterAnimation:
y = self.move_animation_3.attribute
else:
y = 148
dest_rect = ray.Rectangle(start_x + (i * margin), y, game_screen.texture_base_score_numbers[0].width, game_screen.texture_base_score_numbers[0].height)
ray.draw_texture_pro(game_screen.texture_base_score_numbers[int(counter[i])], source_rect, dest_rect, ray.Vector2(0,0), 0, self.color)
dest_rect = ray.Rectangle(start_x + (i * margin), y, game_screen.textures['score_add_1p'][0].width, game_screen.textures['score_add_1p'][0].height)
ray.draw_texture_pro(game_screen.textures['score_add_1p'][int(counter[i])], source_rect, dest_rect, ray.Vector2(0,0), 0, self.color)
class SongInfo:
def __init__(self, current_ms: float, song_name: str, genre: str):
self.fade_in = Animation(current_ms, 366, 'fade')
self.fade_in.params['initial_opacity'] = 0.0
self.fade_in.params['final_opacity'] = 1.0
self.fade_out = Animation(current_ms, 366, 'fade')
self.fade_out.params['initial_opacity'] = 1.0
self.fade_out.params['final_opacity'] = 0.0
self.fade_out.params['delay'] = 1666 + self.fade_in.duration
self.is_finished = False
self.song_num_fade = ray.WHITE
self.song_name_fade = ray.WHITE
codepoint_count = ray.ffi.new('int *', 0)
codepoints_no_dup = set()
codepoints_no_dup.update(song_name)
codepoints = ray.load_codepoints(''.join(codepoints_no_dup), codepoint_count)
self.font = ray.load_font_ex('Graphics\\Modified-DFPKanteiryu-XB.ttf', 32, codepoints, 0)
self.song_title = OutlinedText(self.font, song_name, 40, ray.WHITE, ray.BLACK, outline_thickness=5)
def update(self, current_ms: float):
self.fade_in.update(current_ms)
self.fade_out.update(current_ms)
self.song_num_fade = ray.fade(ray.WHITE, self.fade_in.attribute)
self.song_name_fade = ray.fade(ray.WHITE, 1 - self.fade_in.attribute)
if self.fade_in.is_finished:
self.song_num_fade = ray.fade(ray.WHITE, self.fade_out.attribute)
self.song_name_fade = ray.fade(ray.WHITE, 1 - self.fade_out.attribute)
if self.fade_out.is_finished:
self.fade_in.start_ms = current_ms + 1666
self.fade_out.start_ms = current_ms + 1666
self.fade_in.is_finished = False
self.fade_out.is_finished = False
def draw(self, game_screen: GameScreen):
ray.draw_texture(game_screen.textures['song_info'][(global_data.songs_played % 4) + 8], 1132, 25, self.song_num_fade)
self.song_title.draw(1252 - self.song_title.texture.width, int(50 - self.song_title.texture.height / 2), self.song_name_fade)