working very hard on graphics wrapper

This commit is contained in:
Yonokid
2025-08-10 20:51:45 -04:00
parent 53154e98a1
commit 60fab76c5a
8 changed files with 345 additions and 618 deletions

View File

@@ -1,5 +1,4 @@
import sqlite3 import sqlite3
from pathlib import Path
import pyray as ray import pyray as ray
from raylib import CAMERA_ORTHOGRAPHIC from raylib import CAMERA_ORTHOGRAPHIC
@@ -15,7 +14,6 @@ from libs.utils import (
force_dedicated_gpu, force_dedicated_gpu,
get_config, get_config,
global_data, global_data,
load_all_textures_from_zip,
) )
from scenes.devtest import DevScreen from scenes.devtest import DevScreen
from scenes.entry import EntryScreen from scenes.entry import EntryScreen
@@ -78,7 +76,6 @@ def main():
camera.projection = CAMERA_ORTHOGRAPHIC camera.projection = CAMERA_ORTHOGRAPHIC
ray.init_window(screen_width, screen_height, "PyTaiko") ray.init_window(screen_width, screen_height, "PyTaiko")
global_data.textures = load_all_textures_from_zip(Path('Graphics/lumendata/intermission.zip'))
global_data.tex.load_screen_textures('transition') global_data.tex.load_screen_textures('transition')
if global_data.config["video"]["borderless"]: if global_data.config["video"]["borderless"]:
ray.toggle_borderless_windowed() ray.toggle_borderless_windowed()

View File

@@ -5,7 +5,6 @@ visual_offset = 0
autoplay = false autoplay = false
sfx = true sfx = true
language = "ja" language = "ja"
send_diagnostic_data = false
hard_judge = 108 hard_judge = 108
[paths] [paths]

View File

@@ -112,8 +112,6 @@ class FadeAnimation(BaseAnimation):
def update(self, current_time_ms: float) -> None: def update(self, current_time_ms: float) -> None:
if not self.is_started: if not self.is_started:
return return
else:
self.is_started = not self.is_finished
elapsed_time = current_time_ms - self.start_ms elapsed_time = current_time_ms - self.start_ms
if elapsed_time <= self.delay: if elapsed_time <= self.delay:
@@ -160,8 +158,6 @@ class MoveAnimation(BaseAnimation):
def update(self, current_time_ms: float) -> None: def update(self, current_time_ms: float) -> None:
if not self.is_started: if not self.is_started:
return return
else:
self.is_started = not self.is_finished
elapsed_time = current_time_ms - self.start_ms elapsed_time = current_time_ms - self.start_ms
if elapsed_time < self.delay: if elapsed_time < self.delay:
self.attribute = self.start_position self.attribute = self.start_position
@@ -187,13 +183,12 @@ class TextureChangeAnimation(BaseAnimation):
self.textures = textures self.textures = textures
self.delay = delay self.delay = delay
self.delay_saved = delay self.delay_saved = delay
self.attribute = textures[0][2]
def update(self, current_time_ms: float) -> None: def update(self, current_time_ms: float) -> None:
super().update(current_time_ms) super().update(current_time_ms)
if not self.is_started: if not self.is_started:
return return
else:
self.is_started = not self.is_finished
elapsed_time = current_time_ms - self.start_ms elapsed_time = current_time_ms - self.start_ms
if elapsed_time < self.delay: if elapsed_time < self.delay:
return return
@@ -212,8 +207,6 @@ class TextStretchAnimation(BaseAnimation):
def update(self, current_time_ms: float) -> None: def update(self, current_time_ms: float) -> None:
if not self.is_started: if not self.is_started:
return return
else:
self.is_started = not self.is_finished
elapsed_time = current_time_ms - self.start_ms elapsed_time = current_time_ms - self.start_ms
if elapsed_time <= self.duration: if elapsed_time <= self.duration:
self.attribute = 2 + 5 * (elapsed_time // 25) self.attribute = 2 + 5 * (elapsed_time // 25)

View File

@@ -114,7 +114,7 @@ class TextureWrapper:
raise Exception(f"Texture {tex_name} was not found in {zip}") raise Exception(f"Texture {tex_name} was not found in {zip}")
def draw_texture(self, subset: str, texture: str, color: ray.Color=ray.WHITE, frame: int = 0, scale: float = 1.0, center: bool = False, mirror: str = '', x: int | float = 0, y: int | float = 0, x2: int | float = 0, y2: int | float = 0) -> None: def draw_texture(self, subset: str, texture: str, color: ray.Color=ray.WHITE, frame: int = 0, scale: float = 1.0, center: bool = False, mirror: str = '', x: float = 0, y: float = 0, x2: float = 0, y2: float = 0, origin: ray.Vector2 = ray.Vector2(0,0), rotation: float = 0) -> None:
mirror_x = -1 if mirror == 'horizontal' else 1 mirror_x = -1 if mirror == 'horizontal' else 1
mirror_y = -1 if mirror == 'vertical' else 1 mirror_y = -1 if mirror == 'vertical' else 1
tex_object = self.textures[subset][texture] tex_object = self.textures[subset][texture]
@@ -128,10 +128,10 @@ class TextureWrapper:
raise Exception("Texture was marked as multiframe but is only 1 texture") raise Exception("Texture was marked as multiframe but is only 1 texture")
if frame >= len(tex_object.texture): if frame >= len(tex_object.texture):
raise Exception(f"Frame {frame} not available in iterable texture {tex_object.name}") raise Exception(f"Frame {frame} not available in iterable texture {tex_object.name}")
ray.draw_texture_pro(tex_object.texture[frame], source_rect, dest_rect, ray.Vector2(0, 0), 0, color) ray.draw_texture_pro(tex_object.texture[frame], source_rect, dest_rect, origin, rotation, color)
else: else:
if isinstance(tex_object.texture, list): if isinstance(tex_object.texture, list):
raise Exception("Texture is multiframe but was called as 1 texture") raise Exception("Texture is multiframe but was called as 1 texture")
ray.draw_texture_pro(tex_object.texture, source_rect, dest_rect, ray.Vector2(0, 0), 0, color) ray.draw_texture_pro(tex_object.texture, source_rect, dest_rect, origin, rotation, color)
tex = TextureWrapper() tex = TextureWrapper()

View File

@@ -340,7 +340,7 @@ class TJAParser:
3: 5, 3: 5,
4: 6, 4: 6,
5: 7, 5: 7,
6: 14, 6: 8,
7: 9, 7: 9,
8: 10, 8: 10,
9: 11 9: 11

View File

@@ -39,34 +39,6 @@ def force_dedicated_gpu():
except Exception as e: except Exception as e:
print(e) print(e)
def get_zip_filenames(zip_path: Path) -> list[str]:
result = []
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
file_list = zip_ref.namelist()
for file_name in file_list:
result.append(file_name)
return result
def load_image_from_zip(zip_path: Path, filename: str) -> ray.Image:
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
with zip_ref.open(filename) as image_file:
with tempfile.NamedTemporaryFile(delete=False, suffix='.png') as temp_file:
temp_file.write(image_file.read())
temp_file_path = temp_file.name
image = ray.load_image(temp_file_path)
os.remove(temp_file_path)
return image
def load_texture_from_zip(zip_path: Path, filename: str) -> ray.Texture:
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
with zip_ref.open(filename) as image_file:
with tempfile.NamedTemporaryFile(delete=False, suffix='.png') as temp_file:
temp_file.write(image_file.read())
temp_file_path = temp_file.name
texture = ray.load_texture(temp_file_path)
os.remove(temp_file_path)
return texture
def load_all_textures_from_zip(zip_path: Path) -> dict[str, list[ray.Texture]]: def load_all_textures_from_zip(zip_path: Path) -> dict[str, list[ray.Texture]]:
result_dict = dict() result_dict = dict()
with zipfile.ZipFile(zip_path, 'r') as zip_ref: with zipfile.ZipFile(zip_path, 'r') as zip_ref:
@@ -250,7 +222,6 @@ def reset_session():
@dataclass @dataclass
class GlobalData: class GlobalData:
selected_song: Path = Path() selected_song: Path = Path()
textures: dict[str, list[ray.Texture]] = field(default_factory=lambda: dict())
tex: TextureWrapper = field(default_factory=lambda: TextureWrapper()) tex: TextureWrapper = field(default_factory=lambda: TextureWrapper())
songs_played: int = 0 songs_played: int = 0
config: dict = field(default_factory=lambda: dict()) config: dict = field(default_factory=lambda: dict())

View File

@@ -10,6 +10,7 @@ import pyray as ray
from libs.animation import Animation from libs.animation import Animation
from libs.audio import audio from libs.audio import audio
from libs.backgrounds import Background from libs.backgrounds import Background
from libs.texture import tex
from libs.tja import Balloon, Drumroll, Note, TJAParser, calculate_base_score from libs.tja import Balloon, Drumroll, Note, TJAParser, calculate_base_score
from libs.transition import Transition from libs.transition import Transition
from libs.utils import ( from libs.utils import (
@@ -20,9 +21,6 @@ from libs.utils import (
is_l_kat_pressed, is_l_kat_pressed,
is_r_don_pressed, is_r_don_pressed,
is_r_kat_pressed, is_r_kat_pressed,
load_all_textures_from_zip,
load_image_from_zip,
load_texture_from_zip,
session_data, session_data,
) )
from libs.video import VideoPlayer from libs.video import VideoPlayer
@@ -34,56 +32,12 @@ class GameScreen:
self.width = width self.width = width
self.height = height self.height = height
self.current_ms = 0 self.current_ms = 0
self.result_transition = None
self.transition = None
self.song_info = None
self.screen_init = False self.screen_init = False
self.movie = None self.movie = None
self.end_ms = 0 self.end_ms = 0
self.start_delay = 1000 self.start_delay = 1000
self.song_started = False self.song_started = False
def load_textures(self):
self.textures = load_all_textures_from_zip(Path('Graphics/lumendata/enso_system/common.zip'))
zip_file = Path('Graphics/lumendata/enso_system/common.zip')
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)
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_combo_text = [load_texture_from_zip(zip_file, 'lane_obi_img00035.png'),
load_texture_from_zip(zip_file, 'lane_obi_img00046.png')]
self.texture_combo_numbers = []
for i in range(36, 58):
if i not in [46, 48]:
filename = f'lane_obi_img{str(i).zfill(5)}.png'
self.texture_combo_numbers.append(load_texture_from_zip(zip_file, filename))
self.texture_combo_glimmer = load_texture_from_zip(zip_file, 'lane_obi_img00048.png')
self.texture_se_moji = []
for i in range(0, 17):
filename = f'onp_moji_img{str(i).zfill(5)}.png'
if i == 8:
filename = 'onp_renda_moji_img00001.png'
self.texture_se_moji.append(load_texture_from_zip(zip_file, filename))
self.textures.update(load_all_textures_from_zip(Path('Graphics/lumendata/enso_system/base1p.zip')))
self.textures.update(load_all_textures_from_zip(Path('Graphics/lumendata/enso_system/don1p.zip')))
def load_sounds(self): def load_sounds(self):
sounds_dir = Path("Sounds") sounds_dir = Path("Sounds")
self.sound_don = audio.load_sound(sounds_dir / "inst_00_don.wav") self.sound_don = audio.load_sound(sounds_dir / "inst_00_don.wav")
@@ -94,17 +48,6 @@ class GameScreen:
self.sounds = [self.sound_don, self.sound_kat, self.sound_balloon_pop, self.sound_result_transition] self.sounds = [self.sound_don, self.sound_kat, self.sound_balloon_pop, self.sound_result_transition]
def init_tja(self, song: Path, difficulty: int): def init_tja(self, song: Path, difficulty: int):
#Map notes to textures
self.note_type_list = [self.textures['lane_syousetsu'][0],
self.textures['onp_don'], self.textures['onp_katsu'],
self.textures['onp_don_dai'], self.textures['onp_katsu_dai'],
[self.textures['onp_renda'][2], self.textures['onp_renda'][3]],
[self.textures['onp_renda_dai'][2], self.textures['onp_renda_dai'][3]],
[self.textures['onp_fusen'][1], self.textures['onp_fusen'][2]],
self.textures['onp_renda'][0], self.textures['onp_renda'][1],
self.textures['onp_renda_dai'][0], self.textures['onp_renda_dai'][1],
self.textures['onp_fusen'][0]]
if song == Path(''): if song == Path(''):
self.start_ms = get_current_ms() self.start_ms = get_current_ms()
self.tja = None self.tja = None
@@ -129,12 +72,12 @@ class GameScreen:
def on_screen_start(self): def on_screen_start(self):
if not self.screen_init: if not self.screen_init:
self.screen_init = True self.screen_init = True
tex.load_screen_textures('game')
self.background = Background(self.width, self.height) self.background = Background(self.width, self.height)
self.load_textures()
self.load_sounds() self.load_sounds()
self.init_tja(global_data.selected_song, session_data.selected_difficulty) self.init_tja(global_data.selected_song, session_data.selected_difficulty)
self.song_info = SongInfo(session_data.song_title, 'TEST') self.song_info = SongInfo(session_data.song_title, 'TEST')
self.result_transition = None self.result_transition = ResultTransition()
if self.tja is not None: if self.tja is not None:
subtitle = self.tja.metadata.subtitle.get(global_data.config['general']['language'].lower(), '') subtitle = self.tja.metadata.subtitle.get(global_data.config['general']['language'].lower(), '')
else: else:
@@ -145,9 +88,7 @@ class GameScreen:
def on_screen_end(self, next_screen): def on_screen_end(self, next_screen):
self.screen_init = False self.screen_init = False
for zip in self.textures: tex.unload_textures()
for texture in self.textures[zip]:
ray.unload_texture(texture)
if self.song_music is not None: if self.song_music is not None:
audio.unload_sound(self.song_music) audio.unload_sound(self.song_music)
del self.song_music del self.song_music
@@ -184,8 +125,7 @@ class GameScreen:
def update(self): def update(self):
self.on_screen_start() self.on_screen_start()
if self.transition is not None: self.transition.update(get_current_ms())
self.transition.update(get_current_ms())
self.current_ms = get_current_ms() - self.start_ms self.current_ms = get_current_ms() - self.start_ms
if self.tja is not None: if self.tja is not None:
if (self.current_ms >= self.tja.metadata.offset*1000 + self.start_delay - global_data.config["general"]["judge_offset"]) and not self.song_started: if (self.current_ms >= self.tja.metadata.offset*1000 + self.start_delay - global_data.config["general"]["judge_offset"]) and not self.song_started:
@@ -202,20 +142,19 @@ class GameScreen:
self.background.update(get_current_ms(), self.player_1.gauge.gauge_length > self.player_1.gauge.clear_start[min(self.player_1.difficulty, 3)]) self.background.update(get_current_ms(), self.player_1.gauge.gauge_length > self.player_1.gauge.clear_start[min(self.player_1.difficulty, 3)])
self.player_1.update(self) self.player_1.update(self)
if self.song_info is not None: self.song_info.update(get_current_ms())
self.song_info.update(get_current_ms())
if self.result_transition is not None: self.result_transition.update(get_current_ms())
self.result_transition.update(get_current_ms()) if self.result_transition.is_finished:
if self.result_transition.is_finished: return self.on_screen_end('RESULT')
return self.on_screen_end('RESULT')
elif len(self.player_1.play_notes) == 0: elif len(self.player_1.play_notes) == 0:
session_data.result_score, session_data.result_good, session_data.result_ok, session_data.result_bad, session_data.result_max_combo, session_data.result_total_drumroll = self.player_1.get_result_score() session_data.result_score, session_data.result_good, session_data.result_ok, session_data.result_bad, session_data.result_max_combo, session_data.result_total_drumroll = self.player_1.get_result_score()
session_data.result_gauge_length = self.player_1.gauge.gauge_length session_data.result_gauge_length = self.player_1.gauge.gauge_length
if self.end_ms != 0: if self.end_ms != 0:
if get_current_ms() >= self.end_ms + 8533.34: if get_current_ms() >= self.end_ms + 8533.34:
self.result_transition = ResultTransition(self.height) if not self.result_transition.is_started:
audio.play_sound(self.sound_result_transition) self.result_transition.start()
audio.play_sound(self.sound_result_transition)
else: else:
self.write_score() self.write_score()
self.end_ms = get_current_ms() self.end_ms = get_current_ms()
@@ -236,12 +175,9 @@ class GameScreen:
else: else:
self.background.draw() self.background.draw()
self.player_1.draw(self) self.player_1.draw(self)
if self.song_info is not None: self.song_info.draw()
self.song_info.draw(self) self.transition.draw()
if self.transition is not None: self.result_transition.draw()
self.transition.draw()
if self.result_transition is not None:
self.result_transition.draw(self.width, self.height, global_data.textures['shutter'][0], global_data.textures['shutter'][1])
def draw_3d(self): def draw_3d(self):
self.player_1.draw_3d() self.player_1.draw_3d()
@@ -406,30 +342,25 @@ class Player:
self.play_note_manager(game_screen) self.play_note_manager(game_screen)
self.draw_note_manager(game_screen) self.draw_note_manager(game_screen)
def note_correct(self, game_screen: GameScreen, note: Note): def note_correct(self, note: Note):
self.play_notes.popleft() self.play_notes.popleft()
index = note.index index = note.index
if note.type == 7: if note.type == 7:
note_type = game_screen.note_type_list[3][0]
self.play_notes.popleft() self.play_notes.popleft()
else:
note_type = game_screen.note_type_list[note.type][0]
if note.type < 7: if note.type < 7:
self.combo += 1 self.combo += 1
if self.combo > self.max_combo: if self.combo > self.max_combo:
self.max_combo = self.combo self.max_combo = self.combo
self.draw_arc_list.append(NoteArc(note_type, get_current_ms(), self.player_number, note.type == 3 or note.type == 4) or note.type == 7) self.draw_arc_list.append(NoteArc(note.type, get_current_ms(), self.player_number, note.type == 3 or note.type == 4) or note.type == 7)
#game_screen.background.chibis.append(game_screen.background.Chibi())
if note in self.current_notes_draw: if note in self.current_notes_draw:
index = self.current_notes_draw.index(note) index = self.current_notes_draw.index(note)
self.current_notes_draw.pop(index) self.current_notes_draw.pop(index)
def check_drumroll(self, game_screen: GameScreen, drum_type: int): def check_drumroll(self, drum_type: int):
note_type = game_screen.note_type_list[drum_type][0] self.draw_arc_list.append(NoteArc(drum_type, get_current_ms(), self.player_number, drum_type == 3 or drum_type == 4))
self.draw_arc_list.append(NoteArc(note_type, get_current_ms(), self.player_number, drum_type == 3 or drum_type == 4))
self.curr_drumroll_count += 1 self.curr_drumroll_count += 1
self.total_drumroll += 1 self.total_drumroll += 1
self.score += 100 self.score += 100
@@ -450,9 +381,9 @@ class Player:
if self.curr_balloon_count == note.count: if self.curr_balloon_count == note.count:
self.is_balloon = False self.is_balloon = False
note.popped = True note.popped = True
self.balloon_anim.update(game_screen, get_current_ms(), self.curr_balloon_count, note.popped) self.balloon_anim.update(get_current_ms(), self.curr_balloon_count, note.popped)
audio.play_sound(game_screen.sound_balloon_pop) audio.play_sound(game_screen.sound_balloon_pop)
self.note_correct(game_screen, self.play_notes[0]) self.note_correct(self.play_notes[0])
def check_note(self, game_screen: GameScreen, drum_type: int): def check_note(self, game_screen: GameScreen, drum_type: int):
if len(self.play_notes) == 0: if len(self.play_notes) == 0:
@@ -460,7 +391,7 @@ class Player:
curr_note = self.play_notes[0] curr_note = self.play_notes[0]
if self.is_drumroll: if self.is_drumroll:
self.check_drumroll(game_screen, drum_type) self.check_drumroll(drum_type)
elif self.is_balloon: elif self.is_balloon:
if not isinstance(curr_note, Balloon): if not isinstance(curr_note, Balloon):
raise Exception("Balloon mode entered but current note is not balloon") raise Exception("Balloon mode entered but current note is not balloon")
@@ -489,7 +420,7 @@ class Player:
self.good_count += 1 self.good_count += 1
self.score += self.base_score self.score += self.base_score
self.base_score_list.append(ScoreCounterAnimation(self.base_score)) self.base_score_list.append(ScoreCounterAnimation(self.base_score))
self.note_correct(game_screen, curr_note) self.note_correct(curr_note)
self.gauge.add_good() self.gauge.add_good()
elif (curr_note.hit_ms - Player.TIMING_OK) <= game_screen.current_ms <= (curr_note.hit_ms + Player.TIMING_OK): elif (curr_note.hit_ms - Player.TIMING_OK) <= game_screen.current_ms <= (curr_note.hit_ms + Player.TIMING_OK):
@@ -497,7 +428,7 @@ class Player:
self.ok_count += 1 self.ok_count += 1
self.score += 10 * math.floor(self.base_score / 2 / 10) self.score += 10 * math.floor(self.base_score / 2 / 10)
self.base_score_list.append(ScoreCounterAnimation(10 * math.floor(self.base_score / 2 / 10))) self.base_score_list.append(ScoreCounterAnimation(10 * math.floor(self.base_score / 2 / 10)))
self.note_correct(game_screen, curr_note) self.note_correct(curr_note)
self.gauge.add_ok() self.gauge.add_ok()
elif (curr_note.hit_ms - Player.TIMING_BAD) <= game_screen.current_ms <= (curr_note.hit_ms + Player.TIMING_BAD): elif (curr_note.hit_ms - Player.TIMING_BAD) <= game_screen.current_ms <= (curr_note.hit_ms + Player.TIMING_BAD):
@@ -507,7 +438,7 @@ class Player:
self.play_notes.popleft() self.play_notes.popleft()
self.gauge.add_bad() self.gauge.add_bad()
def drumroll_counter_manager(self, game_screen: GameScreen): def drumroll_counter_manager(self):
if self.is_drumroll and self.curr_drumroll_count > 0 and self.drumroll_counter is None: if self.is_drumroll and self.curr_drumroll_count > 0 and self.drumroll_counter is None:
self.drumroll_counter = DrumrollCounter(get_current_ms()) self.drumroll_counter = DrumrollCounter(get_current_ms())
@@ -515,11 +446,11 @@ class Player:
if self.drumroll_counter.is_finished and not self.is_drumroll: if self.drumroll_counter.is_finished and not self.is_drumroll:
self.drumroll_counter = None self.drumroll_counter = None
else: else:
self.drumroll_counter.update(game_screen, get_current_ms(), self.curr_drumroll_count) self.drumroll_counter.update(get_current_ms(), self.curr_drumroll_count)
def balloon_manager(self, game_screen: GameScreen): def balloon_manager(self):
if self.balloon_anim is not None: if self.balloon_anim is not None:
self.balloon_anim.update(game_screen, get_current_ms(), self.curr_balloon_count, not self.is_balloon) self.balloon_anim.update(get_current_ms(), self.curr_balloon_count, not self.is_balloon)
if self.balloon_anim.is_finished: if self.balloon_anim.is_finished:
self.balloon_anim = None self.balloon_anim = None
@@ -595,17 +526,17 @@ class Player:
def update(self, game_screen: GameScreen): def update(self, game_screen: GameScreen):
self.note_manager(game_screen) self.note_manager(game_screen)
self.combo_display.update(game_screen, get_current_ms(), self.combo) self.combo_display.update(get_current_ms(), self.combo)
self.drumroll_counter_manager(game_screen) self.drumroll_counter_manager()
self.animation_manager(self.draw_judge_list) self.animation_manager(self.draw_judge_list)
self.balloon_manager(game_screen) self.balloon_manager()
if self.lane_hit_effect is not None: if self.lane_hit_effect is not None:
self.lane_hit_effect.update(get_current_ms()) self.lane_hit_effect.update(get_current_ms())
self.animation_manager(self.draw_drum_hit_list) self.animation_manager(self.draw_drum_hit_list)
for anim in self.draw_arc_list: for anim in self.draw_arc_list:
anim.update(get_current_ms()) anim.update(get_current_ms())
if anim.is_finished: if anim.is_finished:
self.gauge_hit_effect.append(GaugeHitEffect(anim.texture, anim.is_big)) self.gauge_hit_effect.append(GaugeHitEffect(anim.note_type, anim.is_big))
self.draw_arc_list.remove(anim) self.draw_arc_list.remove(anim)
self.animation_manager(self.gauge_hit_effect) self.animation_manager(self.gauge_hit_effect)
self.animation_manager(self.base_score_list) self.animation_manager(self.base_score_list)
@@ -613,39 +544,29 @@ class Player:
self.autoplay_manager(game_screen) self.autoplay_manager(game_screen)
self.handle_input(game_screen) self.handle_input(game_screen)
self.gauge.update(get_current_ms(), self.good_count, self.ok_count, self.bad_count, self.total_notes) self.gauge.update(get_current_ms())
def draw_drumroll(self, game_screen: GameScreen, head: Drumroll, current_eighth: int): def draw_drumroll(self, game_screen: GameScreen, head: Drumroll, current_eighth: int):
start_position = self.get_position_x(game_screen.width, game_screen.current_ms, head.load_ms, head.pixels_per_frame_x) start_position = self.get_position_x(game_screen.width, game_screen.current_ms, head.load_ms, head.pixels_per_frame_x)
tail = next((note for note in self.current_notes_draw[1:] if note.type == 8 and note.index > head.index), None) tail = next((note for note in self.current_notes_draw[1:] if note.type == 8 and note.index > head.index), self.current_notes_draw[1])
if tail is None: is_big = int(head.type == 6)
raise Exception("Tail for Balloon not found")
is_big = int(head.type == 6) * 2
end_position = self.get_position_x(game_screen.width, game_screen.current_ms, tail.load_ms, tail.pixels_per_frame_x) end_position = self.get_position_x(game_screen.width, game_screen.current_ms, tail.load_ms, tail.pixels_per_frame_x)
length = (end_position - start_position - 50) length = (end_position - start_position - 50)
if length <= 0: if length <= 0:
end_position += 50 end_position += 50
source_rect = ray.Rectangle(0,0,game_screen.note_type_list[8].width, game_screen.note_type_list[8].height)
dest_rect = ray.Rectangle(start_position+64, 192, length, game_screen.note_type_list[1][0].height)
color = ray.Color(255, head.color, head.color, 255) color = ray.Color(255, head.color, head.color, 255)
ray.draw_texture_pro(game_screen.note_type_list[8 + is_big], source_rect, dest_rect, ray.Vector2(0,0), 0, color) tex.draw_texture('notes', "8", frame=is_big, x=start_position+64, y=192, x2=length, color=color)
ray.draw_texture(game_screen.note_type_list[9 + is_big], end_position, 192, color) tex.draw_texture('notes', "9", frame=is_big, x=end_position, y=192, color=color)
ray.draw_texture(game_screen.note_type_list[head.type][current_eighth % 2], start_position, 192, color) tex.draw_texture('notes', str(head.type), frame=current_eighth % 2, x=start_position, y=192, color=color)
source_rect = ray.Rectangle(0,0,game_screen.texture_se_moji[8].width,game_screen.texture_se_moji[8].height) tex.draw_texture('notes', 'moji_drumroll_mid', x=start_position + 60, y=323, x2=length)
dest_rect = ray.Rectangle(start_position - (game_screen.texture_se_moji[8].width // 2) + 64, 323, length,game_screen.texture_se_moji[8].height) tex.draw_texture('notes', 'moji', frame=head.moji, x=(start_position - (168//2)) + 64, y=323)
ray.draw_texture_pro(game_screen.texture_se_moji[8], source_rect, dest_rect, ray.Vector2(0,0), 0, ray.WHITE) tex.draw_texture('notes', 'moji', frame=tail.moji, x=(end_position - (168//2)) + 32, y=323)
moji_texture = game_screen.texture_se_moji[head.moji]
ray.draw_texture(moji_texture, start_position - (moji_texture.width//2) + 64, 323, ray.WHITE)
moji_texture = game_screen.texture_se_moji[tail.moji]
ray.draw_texture(moji_texture, (end_position - (moji_texture.width//2)) + 32, 323, ray.WHITE)
def draw_balloon(self, game_screen: GameScreen, head: Balloon, current_eighth: int): def draw_balloon(self, game_screen: GameScreen, head: Balloon, current_eighth: int):
offset = 12 offset = 12
start_position = self.get_position_x(game_screen.width, game_screen.current_ms, head.load_ms, head.pixels_per_frame_x) start_position = self.get_position_x(game_screen.width, game_screen.current_ms, head.load_ms, head.pixels_per_frame_x)
tail = next((note for note in self.current_notes_draw[1:] if note.type == 8 and note.index > head.index), None) tail = next((note for note in self.current_notes_draw[1:] if note.type == 8 and note.index > head.index), self.current_notes_draw[1])
if tail is None:
raise Exception("Tail for Balloon not found")
end_position = self.get_position_x(game_screen.width, game_screen.current_ms, tail.load_ms, tail.pixels_per_frame_x) end_position = self.get_position_x(game_screen.width, game_screen.current_ms, tail.load_ms, tail.pixels_per_frame_x)
pause_position = 349 pause_position = 349
if game_screen.current_ms >= tail.hit_ms: if game_screen.current_ms >= tail.hit_ms:
@@ -654,8 +575,8 @@ class Player:
position = pause_position position = pause_position
else: else:
position = start_position position = start_position
ray.draw_texture(game_screen.note_type_list[head.type][current_eighth % 2], position-offset, 192, ray.WHITE) tex.draw_texture('notes', str(head.type), frame=current_eighth % 2, x=position-offset, y=192)
ray.draw_texture(game_screen.note_type_list[12], position-offset+128, 192, ray.WHITE) tex.draw_texture('notes', '10', frame=current_eighth % 2, x=position-offset+128, y=192)
def draw_bars(self, game_screen: GameScreen): def draw_bars(self, game_screen: GameScreen):
if len(self.current_bars) <= 0: if len(self.current_bars) <= 0:
@@ -666,7 +587,7 @@ class Player:
continue continue
x_position = self.get_position_x(game_screen.width, game_screen.current_ms, bar.load_ms, bar.pixels_per_frame_x) x_position = self.get_position_x(game_screen.width, game_screen.current_ms, bar.load_ms, bar.pixels_per_frame_x)
y_position = self.get_position_y(game_screen.current_ms, bar.load_ms, bar.pixels_per_frame_y, bar.pixels_per_frame_x) y_position = self.get_position_y(game_screen.current_ms, bar.load_ms, bar.pixels_per_frame_y, bar.pixels_per_frame_x)
ray.draw_texture(game_screen.note_type_list[bar.type], x_position + 60, y_position + 190, ray.WHITE) tex.draw_texture('notes', str(bar.type), x=x_position+60, y=y_position+190)
def draw_notes(self, game_screen: GameScreen): def draw_notes(self, game_screen: GameScreen):
if len(self.current_notes_draw) <= 0: if len(self.current_notes_draw) <= 0:
@@ -697,50 +618,42 @@ class Player:
self.draw_drumroll(game_screen, note, current_eighth) self.draw_drumroll(game_screen, note, current_eighth)
elif isinstance(note, Balloon): elif isinstance(note, Balloon):
self.draw_balloon(game_screen, note, current_eighth) self.draw_balloon(game_screen, note, current_eighth)
moji_texture = game_screen.texture_se_moji[note.moji] tex.draw_texture('notes', 'moji', frame=note.moji, x=x_position - (168//2) + 64, y=323 + y_position)
ray.draw_texture(moji_texture, x_position - (moji_texture.width//2) + 64, 323 + y_position, ray.WHITE)
else: else:
ray.draw_texture(game_screen.note_type_list[note.type][current_eighth % 2], x_position, y_position + 192, ray.WHITE) tex.draw_texture('notes', str(note.type), frame=current_eighth % 2, x=x_position, y=y_position+192)
moji_texture = game_screen.texture_se_moji[note.moji] tex.draw_texture('notes', 'moji', frame=note.moji, x=x_position - (168//2) + 64, y=323 + y_position)
ray.draw_texture(moji_texture, x_position - (moji_texture.width//2) + 64, 323 + y_position, ray.WHITE)
#ray.draw_text(str(note.index), position+64, 192, 25, ray.GREEN)
def draw(self, game_screen: GameScreen): def draw(self, game_screen: GameScreen):
ray.draw_texture(game_screen.textures['lane'][0], 332, 184, ray.WHITE) tex.draw_texture('lane', 'lane_background')
self.gauge.draw(game_screen.textures['gage_don_1p_hard']) self.gauge.draw()
if self.lane_hit_effect is not None: if self.lane_hit_effect is not None:
self.lane_hit_effect.draw(game_screen.textures['lane_hit']) self.lane_hit_effect.draw()
ray.draw_texture(game_screen.textures['lane_hit'][17], 342, 184, ray.WHITE) tex.draw_texture('lane', 'lane_hit_circle')
for anim in self.draw_judge_list: for anim in self.draw_judge_list:
anim.draw(game_screen.textures['lane_hit'], game_screen.textures['lane_hit_effect']) anim.draw()
#ray.draw_texture(game_screen.textures['onp_kiseki_don_1p'][0], 350, 192, ray.WHITE)
#ray.draw_texture(game_screen.textures['onp_kiseki_don_1p'][22], 332, -84, ray.WHITE)
#ray.draw_texture(game_screen.textures['onp_kiseki_don_1p'][6], 1187 - 29, 130 - 29, ray.WHITE)
self.draw_bars(game_screen) self.draw_bars(game_screen)
self.draw_notes(game_screen) self.draw_notes(game_screen)
ray.draw_texture(game_screen.textures['lane_obi'][0], 0, 184, ray.WHITE) tex.draw_texture('lane', 'lane_cover')
ray.draw_texture(game_screen.textures['lane_obi'][14], 211, 206, ray.WHITE) tex.draw_texture('lane', 'drum')
if global_data.config["general"]["autoplay"]: if global_data.config["general"]["autoplay"]:
ray.draw_texture(game_screen.textures['lane_obi'][58], 0, 290, ray.WHITE) tex.draw_texture('lane', 'auto_icon')
for anim in self.draw_drum_hit_list: for anim in self.draw_drum_hit_list:
anim.draw(game_screen) anim.draw()
self.combo_display.draw(game_screen) self.combo_display.draw()
ray.draw_texture(game_screen.textures['lane_obi'][3], 0, 184, ray.WHITE) tex.draw_texture('lane', 'lane_score_cover')
ray.draw_texture(game_screen.textures['lane_obi'][19], 0, 225, ray.WHITE) tex.draw_texture('lane', '1p_icon')
ray.draw_texture(game_screen.textures['lane_obi'][self.difficulty+21], 50, 222, ray.WHITE) tex.draw_texture('lane', 'lane_difficulty', frame=self.difficulty)
if self.drumroll_counter is not None: if self.drumroll_counter is not None:
self.drumroll_counter.draw(game_screen) self.drumroll_counter.draw()
for anim in self.draw_arc_list: for anim in self.draw_arc_list:
anim.draw(game_screen) anim.draw()
for anim in self.gauge_hit_effect: for anim in self.gauge_hit_effect:
anim.draw(game_screen) anim.draw()
if self.balloon_anim is not None: if self.balloon_anim is not None:
self.balloon_anim.draw(game_screen) self.balloon_anim.draw()
self.score_counter.draw(game_screen) self.score_counter.draw()
for anim in self.base_score_list: for anim in self.base_score_list:
anim.draw(game_screen) anim.draw()
#ray.draw_circle(game_screen.width//2, game_screen.height, 300, ray.ORANGE) #ray.draw_circle(game_screen.width//2, game_screen.height, 300, ray.ORANGE)
def draw_3d(self): def draw_3d(self):
@@ -772,7 +685,7 @@ class Judgement:
self.fade_animation_2.start() self.fade_animation_2.start()
self.move_animation = Animation.create_move(83, total_distance=15, start_position=144) self.move_animation = Animation.create_move(83, total_distance=15, start_position=144)
self.move_animation.start() self.move_animation.start()
self.texture_animation = Animation.create_texture_change(100, textures=[(33, 50, 1), (50, 83, 2), (83, 100, 3), (100, float('inf'), 4)]) self.texture_animation = Animation.create_texture_change(100, textures=[(33, 50, 0), (50, 83, 1), (83, 100, 2), (100, float('inf'), 3)])
self.texture_animation.start() self.texture_animation.start()
def update(self, current_ms): def update(self, current_ms):
@@ -784,7 +697,7 @@ class Judgement:
if self.fade_animation_2.is_finished: if self.fade_animation_2.is_finished:
self.is_finished = True self.is_finished = True
def draw(self, textures_1: list[ray.Texture], textures_2: list[ray.Texture]): def draw(self):
y = self.move_animation.attribute y = self.move_animation.attribute
index = int(self.texture_animation.attribute) index = int(self.texture_animation.attribute)
hit_color = ray.fade(ray.WHITE, self.fade_animation_1.attribute) hit_color = ray.fade(ray.WHITE, self.fade_animation_1.attribute)
@@ -796,28 +709,28 @@ class Judgement:
color = ray.fade(ray.RED, self.fade_animation_2.attribute) color = ray.fade(ray.RED, self.fade_animation_2.attribute)
if self.type == 'GOOD': if self.type == 'GOOD':
if self.big: if self.big:
ray.draw_texture(textures_1[21], 342, 184, color) tex.draw_texture('hit_effect', 'hit_effect_good_big', color=color)
ray.draw_texture(textures_2[index+11], 304, 143, hit_color) tex.draw_texture('hit_effect', 'outer_good_big', frame=index, color=hit_color)
else: else:
ray.draw_texture(textures_1[19], 342, 184, color) tex.draw_texture('hit_effect', 'hit_effect_good', color=color)
ray.draw_texture(textures_2[index+5], 304, 143, hit_color) tex.draw_texture('hit_effect', 'outer_good', frame=index, color=hit_color)
ray.draw_texture(textures_2[9], 370, int(y), color) tex.draw_texture('hit_effect', 'judge_good', y=y, color=color)
elif self.type == 'OK': elif self.type == 'OK':
if self.big: if self.big:
ray.draw_texture(textures_1[20], 342, 184, color) tex.draw_texture('hit_effect', 'hit_effect_ok_big', color=color)
ray.draw_texture(textures_2[index+16], 304, 143, hit_color) tex.draw_texture('hit_effect', 'outer_ok_big', frame=index, color=hit_color)
else: else:
ray.draw_texture(textures_1[18], 342, 184, color) tex.draw_texture('hit_effect', 'hit_effect_ok', color=color)
ray.draw_texture(textures_2[index], 304, 143, hit_color) tex.draw_texture('hit_effect', 'outer_ok', frame=index, color=hit_color)
ray.draw_texture(textures_2[4], 370, int(y), color) tex.draw_texture('hit_effect', 'judge_ok', y=y, color=color)
elif self.type == 'BAD': elif self.type == 'BAD':
ray.draw_texture(textures_2[10], 370, int(y), color) tex.draw_texture('hit_effect', 'judge_bad', y=y, color=color)
class LaneHitEffect: class LaneHitEffect:
def __init__(self, type: str): def __init__(self, type: str):
self.type = type self.type = type
self.color = ray.fade(ray.WHITE, 0.5) self.color = ray.fade(ray.WHITE, 0.5)
self.fade = Animation.create_fade(150, delay=83, initial_opacity=0.5) self.fade = tex.get_animation(0, is_copy=True)
self.fade.start() self.fade.start()
self.is_finished = False self.is_finished = False
@@ -828,13 +741,13 @@ class LaneHitEffect:
if self.fade.is_finished: if self.fade.is_finished:
self.is_finished = True self.is_finished = True
def draw(self, textures: list[ray.Texture]): def draw(self):
if self.type == 'GOOD': if self.type == 'GOOD':
ray.draw_texture(textures[7], 328, 192, self.color) tex.draw_texture('lane', 'lane_hit_effect', frame=2, color=self.color)
elif self.type == 'DON': elif self.type == 'DON':
ray.draw_texture(textures[5], 328, 192, self.color) tex.draw_texture('lane', 'lane_hit_effect', frame=0, color=self.color)
elif self.type == 'KAT': elif self.type == 'KAT':
ray.draw_texture(textures[6], 328, 192, self.color) tex.draw_texture('lane', 'lane_hit_effect', frame=1, color=self.color)
class DrumHitEffect: class DrumHitEffect:
def __init__(self, type: str, side: str): def __init__(self, type: str, side: str):
@@ -842,7 +755,7 @@ class DrumHitEffect:
self.side = side self.side = side
self.color = ray.fade(ray.WHITE, 1) self.color = ray.fade(ray.WHITE, 1)
self.is_finished = False self.is_finished = False
self.fade = Animation.create_fade(100, delay=67) self.fade = tex.get_animation(1, is_copy=True)
self.fade.start() self.fade.start()
def update(self, current_ms: float): def update(self, current_ms: float):
@@ -852,24 +765,23 @@ class DrumHitEffect:
if self.fade.is_finished: if self.fade.is_finished:
self.is_finished = True self.is_finished = True
def draw(self, game_screen): def draw(self):
x, y = 211, 206
if self.type == 'DON': if self.type == 'DON':
if self.side == 'L': if self.side == 'L':
ray.draw_texture(game_screen.textures['lane_obi'][16], x, y, self.color) tex.draw_texture('lane', 'drum_don_l', color=self.color)
elif self.side == 'R': elif self.side == 'R':
ray.draw_texture(game_screen.textures['lane_obi'][15], x, y, self.color) tex.draw_texture('lane', 'drum_don_r', color=self.color)
elif self.type == 'KAT': elif self.type == 'KAT':
if self.side == 'L': if self.side == 'L':
ray.draw_texture(game_screen.textures['lane_obi'][18], x, y, self.color) tex.draw_texture('lane', 'drum_kat_l', color=self.color)
elif self.side == 'R': elif self.side == 'R':
ray.draw_texture(game_screen.textures['lane_obi'][17], x, y, self.color) tex.draw_texture('lane', 'drum_kat_r', color=self.color)
class GaugeHitEffect: class GaugeHitEffect:
def __init__(self, note_texture: ray.Texture, big: bool): def __init__(self, note_type: int, big: bool):
self.note_texture = note_texture self.note_type = note_type
self.is_big = big self.is_big = big
self.texture_change = Animation.create_texture_change(116.67, textures=[(0, 33.33, 1), (33.33, 66.66, 2), (66.66, float('inf'), 3)]) self.texture_change = tex.get_animation(2, is_copy=True)
self.texture_change.start() self.texture_change.start()
self.circle_fadein = Animation.create_fade(133, initial_opacity=0.0, final_opacity=1.0, delay=16.67) self.circle_fadein = Animation.create_fade(133, initial_opacity=0.0, final_opacity=1.0, delay=16.67)
self.circle_fadein.start() self.circle_fadein.start()
@@ -877,8 +789,8 @@ class GaugeHitEffect:
self.resize.start() self.resize.start()
self.fade_out = Animation.create_fade(66, delay=233) self.fade_out = Animation.create_fade(66, delay=233)
self.fade_out.start() self.fade_out.start()
self.test = Animation.create_fade(300, delay=116.67, initial_opacity=0.0, final_opacity=1.0) self.rotation = Animation.create_fade(300, delay=116.67, initial_opacity=0.0, final_opacity=1.0)
self.test.start() self.rotation.start()
self.color = ray.fade(ray.YELLOW, self.circle_fadein.attribute) self.color = ray.fade(ray.YELLOW, self.circle_fadein.attribute)
self.is_finished = False self.is_finished = False
def update(self, current_ms): def update(self, current_ms):
@@ -886,15 +798,14 @@ class GaugeHitEffect:
self.circle_fadein.update(current_ms) self.circle_fadein.update(current_ms)
self.fade_out.update(current_ms) self.fade_out.update(current_ms)
self.resize.update(current_ms) self.resize.update(current_ms)
self.test.update(current_ms) self.rotation.update(current_ms)
color = ray.YELLOW color = ray.YELLOW
if self.circle_fadein.is_finished: if self.circle_fadein.is_finished:
color = ray.WHITE color = ray.WHITE
self.color = ray.fade(color, min(self.fade_out.attribute, self.circle_fadein.attribute)) self.color = ray.fade(color, min(self.fade_out.attribute, self.circle_fadein.attribute))
if self.fade_out.is_finished: if self.fade_out.is_finished:
self.is_finished = True self.is_finished = True
def draw(self, game_screen): def draw(self):
texture = game_screen.textures['onp_kiseki_don_1p'][self.texture_change.attribute]
color_map = {0.70: ray.WHITE, 0.80: ray.YELLOW, 0.90: ray.ORANGE, 1.00: ray.RED} color_map = {0.70: ray.WHITE, 0.80: ray.YELLOW, 0.90: ray.ORANGE, 1.00: ray.RED}
texture_color = ray.WHITE texture_color = ray.WHITE
for upper_bound, color in color_map.items(): for upper_bound, color in color_map.items():
@@ -904,23 +815,20 @@ class GaugeHitEffect:
texture_color = color texture_color = color
elif self.resize.attribute >= upper_bound: elif self.resize.attribute >= upper_bound:
texture_color = ray.RED texture_color = ray.RED
original_x = 1223 dest_width = 152 * self.resize.attribute
original_y = 164 dest_height = 152 * self.resize.attribute
source = ray.Rectangle(0, 0, texture.width, texture.height)
dest_width = texture.width * self.resize.attribute
dest_height = texture.height * self.resize.attribute
dest = ray.Rectangle(original_x, original_y, dest_width, dest_height)
origin = ray.Vector2(dest_width / 2, dest_height / 2) origin = ray.Vector2(dest_width / 2, dest_height / 2)
ray.draw_texture_pro(texture, source, dest, origin, self.test.attribute*100, ray.fade(texture_color, self.fade_out.attribute)) rotation = self.rotation.attribute*100
ray.draw_texture(self.note_texture, 1187 - 29, 130 - 29, ray.fade(ray.WHITE, self.fade_out.attribute)) tex.draw_texture('gauge', 'hit_effect', frame=self.texture_change.attribute, x2=-152 + (152 * self.resize.attribute), y2=-152 + (152 * self.resize.attribute), color=ray.fade(texture_color, self.fade_out.attribute), origin=origin, rotation=rotation, center=True)
tex.draw_texture('notes', str(self.note_type), x=1158, y=101, color=ray.fade(ray.WHITE, self.fade_out.attribute))
if self.is_big: if self.is_big:
ray.draw_texture(game_screen.textures['onp_kiseki_don_1p'][20], 1187 - 29, 130 - 29, self.color) tex.draw_texture('gauge', 'hit_effect_circle_big', color=self.color)
else: else:
ray.draw_texture(game_screen.textures['onp_kiseki_don_1p'][4], 1187 - 29, 130 - 29, self.color) tex.draw_texture('gauge', 'hit_effect_circle', color=self.color)
class NoteArc: class NoteArc:
def __init__(self, note_texture: ray.Texture, current_ms: float, player_number: int, big: bool): def __init__(self, note_type: int, current_ms: float, player_number: int, big: bool):
self.texture = note_texture self.note_type = note_type
self.is_big = big self.is_big = big
self.arc_points = 22 self.arc_points = 22
self.create_ms = current_ms self.create_ms = current_ms
@@ -1004,8 +912,8 @@ class NoteArc:
self.x_i = self.end_x self.x_i = self.end_x
self.y_i = self.end_y self.y_i = self.end_y
def draw(self, game_screen): def draw(self):
ray.draw_texture(self.texture, self.x_i, self.y_i, ray.WHITE) tex.draw_texture('notes', str(self.note_type), x=self.x_i, y=self.y_i)
class DrumrollCounter: class DrumrollCounter:
def __init__(self, current_ms: float): def __init__(self, current_ms: float):
@@ -1013,20 +921,18 @@ class DrumrollCounter:
self.is_finished = False self.is_finished = False
self.total_duration = 1349 self.total_duration = 1349
self.drumroll_count = 0 self.drumroll_count = 0
self.fade_animation = Animation.create_fade(166, delay=self.total_duration - 166) self.fade_animation = tex.get_animation(8)
self.fade_animation.start() self.fade_animation.start()
self.stretch_animation = Animation.create_text_stretch(0) self.stretch_animation = tex.get_animation(9)
self.stretch_animation.start()
def update_count(self, count: int, elapsed_time: float): def update_count(self, count: int, elapsed_time: float):
self.total_duration = elapsed_time + 1349 self.total_duration = elapsed_time + 1349
self.fade_animation.delay = self.total_duration - 166 self.fade_animation.delay = self.total_duration - 166
if self.drumroll_count != count: if self.drumroll_count != count:
self.drumroll_count = count self.drumroll_count = count
self.stretch_animation = Animation.create_text_stretch(50)
self.stretch_animation.start() self.stretch_animation.start()
def update(self, game_screen: GameScreen, current_ms: float, drumroll_count: int): def update(self, current_ms: float, drumroll_count: int):
self.stretch_animation.update(current_ms) self.stretch_animation.update(current_ms)
self.fade_animation.update(current_ms) self.fade_animation.update(current_ms)
@@ -1036,16 +942,13 @@ class DrumrollCounter:
if self.fade_animation.is_finished: if self.fade_animation.is_finished:
self.is_finished = True self.is_finished = True
def draw(self, game_screen: GameScreen): def draw(self):
color = ray.fade(ray.WHITE, self.fade_animation.attribute) color = ray.fade(ray.WHITE, self.fade_animation.attribute)
ray.draw_texture(game_screen.textures['renda_num'][0], 200, 0, color) tex.draw_texture('drumroll_counter', 'bubble', color=color)
counter = str(self.drumroll_count) counter = str(self.drumroll_count)
total_width = len(counter) * 52 total_width = len(counter) * 52
start_x = 344 - (total_width // 2)
source_rect = ray.Rectangle(0, 0, game_screen.textures['renda_num'][1].width, game_screen.textures['renda_num'][1].height)
for i in range(len(counter)): for i in range(len(counter)):
dest_rect = ray.Rectangle(start_x + (i * 52), 50 - self.stretch_animation.attribute, game_screen.textures['renda_num'][1].width, game_screen.textures['renda_num'][1].height + self.stretch_animation.attribute) tex.draw_texture('drumroll_counter', 'counter', color=color, frame=int(counter[i]), x=-(total_width//2)+(i*52), y=-self.stretch_animation.attribute, y2=self.stretch_animation.attribute)
ray.draw_texture_pro(game_screen.textures['renda_num'][int(counter[i])+1], source_rect, dest_rect, ray.Vector2(0,0), 0, color)
class BalloonAnimation: class BalloonAnimation:
def __init__(self, current_ms: float, balloon_total: int): def __init__(self, current_ms: float, balloon_total: int):
@@ -1056,18 +959,16 @@ class BalloonAnimation:
self.balloon_count = 0 self.balloon_count = 0
self.balloon_total = balloon_total self.balloon_total = balloon_total
self.is_popped = False self.is_popped = False
self.fade_animation = Animation.create_fade(166) self.stretch_animation = tex.get_animation(6)
self.fade_animation = tex.get_animation(7)
self.fade_animation.start() self.fade_animation.start()
self.stretch_animation = Animation.create_text_stretch(0)
self.stretch_animation.start()
def update_count(self, balloon_count: int): def update_count(self, balloon_count: int):
if self.balloon_count != balloon_count: if self.balloon_count != balloon_count:
self.balloon_count = balloon_count self.balloon_count = balloon_count
self.stretch_animation = Animation.create_text_stretch(50)
self.stretch_animation.start() self.stretch_animation.start()
def update(self, game_screen: GameScreen, current_ms: float, balloon_count: int, is_popped: bool): def update(self, current_ms: float, balloon_count: int, is_popped: bool):
self.update_count(balloon_count) self.update_count(balloon_count)
self.stretch_animation.update(current_ms) self.stretch_animation.update(current_ms)
self.is_popped = is_popped self.is_popped = is_popped
@@ -1082,29 +983,23 @@ class BalloonAnimation:
if self.fade_animation.is_finished: if self.fade_animation.is_finished:
self.is_finished = True self.is_finished = True
def draw(self, game_screen: GameScreen): def draw(self):
if self.is_popped: if self.is_popped:
ray.draw_texture(game_screen.textures['action_fusen_1p'][18], 460, 130, self.color) tex.draw_texture('balloon', 'pop', frame=7, color=self.color)
elif self.balloon_count >= 1: elif self.balloon_count >= 1:
balloon_index = min(7, (self.balloon_count - 1) * 7 // self.balloon_total) balloon_index = min(6, (self.balloon_count - 1) * 6 // self.balloon_total)
ray.draw_texture(game_screen.textures['action_fusen_1p'][balloon_index+11], 460, 130, self.color) tex.draw_texture('balloon', 'pop', frame=balloon_index, color=self.color)
if self.balloon_count > 0: if self.balloon_count > 0:
ray.draw_texture(game_screen.textures['action_fusen_1p'][0], 414, 40, ray.WHITE) tex.draw_texture('balloon', 'bubble')
counter = str(max(0, self.balloon_total - self.balloon_count + 1)) counter = str(max(0, self.balloon_total - self.balloon_count + 1))
x, y = 493, 68 total_width = len(counter) * 52
margin = 52
total_width = len(counter) * margin
start_x = x - (total_width // 2)
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)): for i in range(len(counter)):
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) tex.draw_texture('balloon', 'counter', frame=int(counter[i]), color=self.color, x=-(total_width // 2) + (i * 52), y=-self.stretch_animation.attribute, y2=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: class Combo:
def __init__(self, combo: int, current_ms: float): def __init__(self, combo: int, current_ms: float):
self.combo = combo self.combo = combo
self.stretch_animation = Animation.create_text_stretch(0) self.stretch_animation = tex.get_animation(5)
self.stretch_animation.start()
self.color = [ray.fade(ray.WHITE, 1), ray.fade(ray.WHITE, 1), ray.fade(ray.WHITE, 1)] self.color = [ray.fade(ray.WHITE, 1), ray.fade(ray.WHITE, 1), ray.fade(ray.WHITE, 1)]
self.glimmer_dict = {0: 0, 1: 0, 2: 0} self.glimmer_dict = {0: 0, 1: 0, 2: 0}
self.total_time = 250 self.total_time = 250
@@ -1115,14 +1010,13 @@ class Combo:
current_ms + (4 / 3) * self.cycle_time current_ms + (4 / 3) * self.cycle_time
] ]
def update_count(self, current_ms: float, combo: int): def update_count(self, combo: int):
if self.combo != combo: if self.combo != combo:
self.combo = combo self.combo = combo
self.stretch_animation = Animation.create_text_stretch(50)
self.stretch_animation.start() self.stretch_animation.start()
def update(self, game_screen: GameScreen, current_ms: float, combo: int): def update(self, current_ms: float, combo: int):
self.update_count(current_ms, combo) self.update_count(combo)
self.stretch_animation.update(current_ms) self.stretch_animation.update(current_ms)
for i in range(3): for i in range(3):
@@ -1143,57 +1037,50 @@ class Combo:
fade = 0 fade = 0
self.color[i] = ray.fade(ray.WHITE, fade) self.color[i] = ray.fade(ray.WHITE, fade)
def draw(self, game_screen: GameScreen): def draw(self):
counter = str(self.combo)
if self.combo < 3: if self.combo < 3:
return return
if self.combo < 100: if self.combo < 100:
text_color = 0
margin = 30 margin = 30
total_width = len(counter) * margin
tex.draw_texture('combo', 'combo')
for i in range(len(counter)):
tex.draw_texture('combo', 'counter', frame=int(counter[i]), x=-(total_width // 2) + (i * margin), y=-self.stretch_animation.attribute, y2=self.stretch_animation.attribute)
else: else:
text_color = 1
margin = 35 margin = 35
ray.draw_texture(game_screen.texture_combo_text[text_color], 234, 265, ray.WHITE) total_width = len(counter) * margin
counter = str(self.combo) tex.draw_texture('combo', 'combo_100')
total_width = len(counter) * margin for i in range(len(counter)):
x, y = 262, 220 tex.draw_texture('combo', 'counter_100', frame=int(counter[i]), x=-(total_width // 2) + (i * margin), y=-self.stretch_animation.attribute, y2=self.stretch_animation.attribute)
start_x = x - (total_width // 2) glimmer_positions = [(225, 210), (200, 230), (250, 230)]
source_rect = ray.Rectangle(0, 0, game_screen.texture_combo_numbers[0].width, game_screen.texture_combo_numbers[0].height)
for i in range(len(counter)):
dest_rect = ray.Rectangle(start_x + (i * margin), y - self.stretch_animation.attribute, game_screen.texture_combo_numbers[0].width, game_screen.texture_combo_numbers[0].height + self.stretch_animation.attribute)
ray.draw_texture_pro(game_screen.texture_combo_numbers[int(counter[i]) + (text_color*10)], source_rect, dest_rect, ray.Vector2(0,0), 0, ray.WHITE)
glimmer_positions = [(225, 210), (200, 230), (250, 230)]
if self.combo >= 100:
for j, (x, y) in enumerate(glimmer_positions): for j, (x, y) in enumerate(glimmer_positions):
for i in range(3): for i in range(3):
ray.draw_texture(game_screen.texture_combo_glimmer, x + (i * 30), y + self.glimmer_dict[j], self.color[j]) tex.draw_texture('combo', 'gleam', x=x+(i*30), y=y+self.glimmer_dict[j], color=self.color[j])
class ScoreCounter: class ScoreCounter:
def __init__(self, score: int): def __init__(self, score: int):
self.score = score self.score = score
self.stretch_animation = Animation.create_text_stretch(0) self.stretch = tex.get_animation(4)
self.stretch_animation.start()
def update_count(self, current_ms: float, score: int): def update_count(self, score: int):
if self.score != score: if self.score != score:
self.score = score self.score = score
self.stretch_animation = Animation.create_text_stretch(50) self.stretch.start()
self.stretch_animation.start()
def update(self, current_ms: float, score: int): def update(self, current_ms: float, score: int):
self.update_count(current_ms, score) self.update_count(score)
if self.score > 0: if self.score > 0:
self.stretch_animation.update(current_ms) self.stretch.update(current_ms)
def draw(self, game_screen: GameScreen): def draw(self):
counter = str(self.score) counter = str(self.score)
x, y = 150, 185 x, y = 150, 185
margin = 20 margin = 20
total_width = len(counter) * margin total_width = len(counter) * margin
start_x = x - total_width start_x = x - total_width
source_rect = ray.Rectangle(0, 0, game_screen.textures['lane_obi'][4].width, game_screen.textures['lane_obi'][4].height)
for i in range(len(counter)): for i in range(len(counter)):
dest_rect = ray.Rectangle(start_x + (i * margin), y - self.stretch_animation.attribute, game_screen.textures['lane_obi'][4].width, game_screen.textures['lane_obi'][4].height + self.stretch_animation.attribute) tex.draw_texture('lane', 'score_number', frame=int(counter[i]), x=start_x + (i * margin), y=y - self.stretch.attribute, y2=self.stretch.attribute)
ray.draw_texture_pro(game_screen.textures['lane_obi'][int(counter[i])+4], source_rect, dest_rect, ray.Vector2(0,0), 0, ray.WHITE)
class ScoreCounterAnimation: class ScoreCounterAnimation:
def __init__(self, counter: int): def __init__(self, counter: int):
@@ -1233,7 +1120,7 @@ class ScoreCounterAnimation:
for i in range(1, len(str(self.counter))+1): for i in range(1, len(str(self.counter))+1):
self.y_pos_list.append(self.move_animation_4.attribute + i*5) self.y_pos_list.append(self.move_animation_4.attribute + i*5)
def draw(self, game_screen: GameScreen): def draw(self):
if self.move_animation_1.is_finished: if self.move_animation_1.is_finished:
x = self.move_animation_2.attribute x = self.move_animation_2.attribute
else: else:
@@ -1244,7 +1131,6 @@ class ScoreCounterAnimation:
margin = 20 margin = 20
total_width = len(counter) * margin total_width = len(counter) * margin
start_x = x - total_width start_x = x - total_width
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)): for i in range(len(counter)):
if self.move_animation_3.is_finished: if self.move_animation_3.is_finished:
y = self.y_pos_list[i] y = self.y_pos_list[i]
@@ -1252,87 +1138,53 @@ class ScoreCounterAnimation:
y = self.move_animation_3.attribute y = self.move_animation_3.attribute
else: else:
y = 148 y = 148
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) tex.draw_texture('lane', 'score_number', frame=int(counter[i]), x=start_x + (i * margin), y=y, color=self.color)
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: class SongInfo:
FADE_DURATION = 366
DISPLAY_DURATION = 1666
def __init__(self, song_name: str, genre: str): def __init__(self, song_name: str, genre: str):
self.song_name = song_name self.song_name = song_name
self.genre = genre self.genre = genre
self.song_title = OutlinedText( self.song_title = OutlinedText(song_name, 40, ray.WHITE, ray.BLACK, outline_thickness=5)
song_name, 40, ray.Color(255, 255, 255, 255), ray.Color(0, 0, 0, 255), outline_thickness=5 self.fade = tex.get_animation(3)
) self.fade.start()
self.fade_in = Animation.create_fade(self.FADE_DURATION, initial_opacity=0.0, final_opacity=1.0)
self.fade_in.start()
self.fade_out = Animation.create_fade(self.FADE_DURATION, delay=self.DISPLAY_DURATION)
self.fade_out.start()
self.fade_fake = Animation.create_fade(0, delay=self.DISPLAY_DURATION*2 + self.FADE_DURATION)
self.fade_fake.start()
def update(self, current_ms: float): def update(self, current_ms: float):
self.fade_in.update(current_ms) self.fade.update(current_ms)
self.fade_out.update(current_ms) if self.fade.is_finished:
self.fade_fake.update(current_ms) self.fade.restart()
if not self.fade_in.is_finished: def draw(self):
self.song_num_fade = ray.fade(ray.WHITE, self.fade_in.attribute) tex.draw_texture('song_info', 'song_num', color=ray.fade(ray.WHITE, self.fade.attribute), frame=global_data.songs_played % 4)
self.song_name_fade = ray.fade(ray.WHITE, 1 - self.fade_in.attribute)
else:
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_fake.is_finished:
self._reset_animations(current_ms)
def _reset_animations(self, current_ms: float):
self.fade_in = Animation.create_fade(self.FADE_DURATION, initial_opacity=0.0, final_opacity=1.0)
self.fade_in.start()
self.fade_out = Animation.create_fade(self.FADE_DURATION, delay=self.DISPLAY_DURATION)
self.fade_out.start()
self.fade_fake = Animation.create_fade(0, delay=self.DISPLAY_DURATION*2 + self.FADE_DURATION)
self.fade_fake.start()
def draw(self, game_screen: GameScreen):
song_texture_index = (global_data.songs_played % 4) + 8
ray.draw_texture(
game_screen.textures['song_info'][song_texture_index],
1132, 25,
self.song_num_fade
)
text_x = 1252 - self.song_title.texture.width text_x = 1252 - self.song_title.texture.width
text_y = int(50 - self.song_title.texture.height / 2) text_y = 50 - self.song_title.texture.height//2
src = ray.Rectangle(0, 0, self.song_title.texture.width, self.song_title.texture.height)
dest = ray.Rectangle(text_x, text_y, self.song_title.texture.width, self.song_title.texture.height) dest = ray.Rectangle(text_x, text_y, self.song_title.texture.width, self.song_title.texture.height)
self.song_title.draw(src, dest, ray.Vector2(0, 0), 0, self.song_name_fade) self.song_title.draw(self.song_title.default_src, dest, ray.Vector2(0, 0), 0, ray.fade(ray.WHITE, 1 - self.fade.attribute))
class ResultTransition: class ResultTransition:
def __init__(self, screen_height: int): def __init__(self):
self.move = Animation.create_move(983.33, start_position=0, total_distance=screen_height//2, ease_out='quadratic') self.move = global_data.tex.get_animation(5)
self.move.start() self.move.reset()
self.is_finished = False self.is_finished = False
self.is_started = False
def start(self):
self.move.start()
def update(self, current_ms: float): def update(self, current_ms: float):
self.move.update(current_ms) self.move.update(current_ms)
self.is_started = self.move.is_started
self.is_finished = self.move.is_finished
if self.move.is_finished: def draw(self):
self.is_finished = True
def draw(self, screen_width: int, screen_height: int, texture_1: ray.Texture, texture_2: ray.Texture):
x = 0 x = 0
screen_width = 1280
while x < screen_width: while x < screen_width:
ray.draw_texture(texture_1, x, (0 - texture_1.height) + int(self.move.attribute), ray.WHITE) global_data.tex.draw_texture('result_transition', '1p_shutter', frame=0, x=x, y=-720 + self.move.attribute)
ray.draw_texture(texture_1, x, (screen_height) - int(self.move.attribute), ray.WHITE) global_data.tex.draw_texture('result_transition', '1p_shutter', frame=0, x=x, y=720 - self.move.attribute)
x += texture_1.width global_data.tex.draw_texture('result_transition', '1p_shutter_footer', x=x, y=-432 + self.move.attribute)
x = 0 global_data.tex.draw_texture('result_transition', '1p_shutter_footer', x=x, y=1008 - self.move.attribute)
while x < screen_width: x += 256
ray.draw_texture(texture_2, x, (0 - texture_2.height//2) - (texture_1.height//2) + int(self.move.attribute), ray.WHITE)
ray.draw_texture(texture_2, x, (screen_height) + (texture_1.height//2) - (texture_2.height//2) - int(self.move.attribute), ray.WHITE)
x += texture_2.width
class Gauge: class Gauge:
GAUGE_MAX = 87 GAUGE_MAX = 87
@@ -1413,7 +1265,7 @@ class Gauge:
if self.gauge_length < 0: if self.gauge_length < 0:
self.gauge_length = 0 self.gauge_length = 0
def update(self, current_ms: float, good_count: int, ok_count: int, bad_count: int, total_notes: int): def update(self, current_ms: float):
if self.gauge_length == 87 and self.rainbow_fade_in is None: if self.gauge_length == 87 and self.rainbow_fade_in is None:
self.rainbow_fade_in = Animation.create_fade(450, initial_opacity=0.0, final_opacity=1.0) self.rainbow_fade_in = Animation.create_fade(450, initial_opacity=0.0, final_opacity=1.0)
self.rainbow_fade_in.start() self.rainbow_fade_in.start()
@@ -1434,33 +1286,33 @@ class Gauge:
if self.rainbow_animation.is_finished or self.gauge_length < 87: if self.rainbow_animation.is_finished or self.gauge_length < 87:
self.rainbow_animation = None self.rainbow_animation = None
def draw(self, textures: list[ray.Texture]): def draw(self):
ray.draw_texture(textures[0], 327, 132, ray.WHITE) tex.draw_texture('gauge', 'border')
ray.draw_texture(textures[1], 483, 124, ray.WHITE) tex.draw_texture('gauge', 'unfilled')
gauge_length = int(self.gauge_length) gauge_length = int(self.gauge_length)
for i in range(gauge_length): for i in range(gauge_length):
if i == 68: if i == 68:
ray.draw_texture(textures[16], 491 + (i*textures[13].width), 160 - 24, ray.WHITE) tex.draw_texture('gauge', 'bar_clear_transition', x=i*8)
elif i > 68: elif i > 68:
ray.draw_texture(textures[15], 491 + (i*textures[13].width) + 2, 160 - 22, ray.WHITE) tex.draw_texture('gauge', 'bar_clear_top', x=i*8)
ray.draw_texture(textures[20], 491 + (i*textures[13].width) + 2, 160, ray.WHITE) tex.draw_texture('gauge', 'bar_clear_bottom', x=i*8)
else: else:
ray.draw_texture(textures[13], 491 + (i*textures[13].width), 160, ray.WHITE) tex.draw_texture('gauge', 'bar', x=i*8)
if gauge_length == 87 and self.rainbow_fade_in is not None and self.rainbow_animation is not None: if gauge_length == 87 and self.rainbow_fade_in is not None and self.rainbow_animation is not None:
if 0 < self.rainbow_animation.attribute < 8: if 0 < self.rainbow_animation.attribute < 8:
ray.draw_texture(textures[1 + int(self.rainbow_animation.attribute)], 483, 124, ray.fade(ray.WHITE, self.rainbow_fade_in.attribute)) tex.draw_texture('gauge', 'rainbow', frame=self.rainbow_animation.attribute-1, color=ray.fade(ray.WHITE, self.rainbow_fade_in.attribute))
ray.draw_texture(textures[2 + int(self.rainbow_animation.attribute)], 483, 124, ray.fade(ray.WHITE, self.rainbow_fade_in.attribute)) tex.draw_texture('gauge', 'rainbow', frame=self.rainbow_animation.attribute, color=ray.fade(ray.WHITE, self.rainbow_fade_in.attribute))
if self.gauge_update_anim is not None and gauge_length < 88 and gauge_length != self.previous_length: if self.gauge_update_anim is not None and gauge_length < 88 and gauge_length > self.previous_length:
if gauge_length == 69: if gauge_length == 69:
ray.draw_texture(textures[17], 491 + (gauge_length*textures[13].width) - 13, 160 - 8 - 24, ray.fade(ray.WHITE, self.gauge_update_anim.attribute)) tex.draw_texture('gauge', 'bar_clear_transition_fade', x=gauge_length*8, color=ray.fade(ray.WHITE, self.gauge_update_anim.attribute))
elif gauge_length > 69: elif gauge_length > 69:
ray.draw_texture(textures[21], 491 + (gauge_length*textures[13].width) - 13, 160 - 8 - 22, ray.fade(ray.WHITE, self.gauge_update_anim.attribute)) tex.draw_texture('gauge', 'bar_clear_fade', x=gauge_length*8, color=ray.fade(ray.WHITE, self.gauge_update_anim.attribute))
else: else:
ray.draw_texture(textures[14], 491 + (gauge_length*textures[13].width) - 13, 160 - 8, ray.fade(ray.WHITE, self.gauge_update_anim.attribute)) tex.draw_texture('gauge', 'bar_fade', x=gauge_length*8, color=ray.fade(ray.WHITE, self.gauge_update_anim.attribute))
ray.draw_texture(textures[10], 483, 124, ray.fade(ray.WHITE, 0.15)) tex.draw_texture('gauge', 'overlay', color=ray.fade(ray.WHITE, 0.15))
if gauge_length >= 70: if gauge_length >= 69:
ray.draw_texture(textures[18], 1038, 141, ray.WHITE) tex.draw_texture('gauge', 'clear')
ray.draw_texture(textures[19], 1187, 130, ray.WHITE) tex.draw_texture('gauge', 'tamashii')
else: else:
ray.draw_texture(textures[11], 1038, 141, ray.WHITE) tex.draw_texture('gauge', 'clear_dark')
ray.draw_texture(textures[12], 1187, 130, ray.WHITE) tex.draw_texture('gauge', 'tamashii_dark')

View File

@@ -4,16 +4,14 @@ import pyray as ray
from raylib import SHADER_UNIFORM_FLOAT from raylib import SHADER_UNIFORM_FLOAT
from libs import utils from libs import utils
from libs.animation import Animation
from libs.audio import audio from libs.audio import audio
from libs.texture import tex
from libs.utils import ( from libs.utils import (
OutlinedText, OutlinedText,
draw_scaled_texture,
get_current_ms, get_current_ms,
global_data, global_data,
is_l_don_pressed, is_l_don_pressed,
is_r_don_pressed, is_r_don_pressed,
load_all_textures_from_zip,
session_data, session_data,
) )
@@ -31,8 +29,7 @@ class ResultScreen:
self.alpha_shader = ray.load_shader('', 'shader/grayscale_alpha.fs') self.alpha_shader = ray.load_shader('', 'shader/grayscale_alpha.fs')
def load_textures(self): def load_textures(self):
zip_file = Path('Graphics/lumendata/enso_result.zip') tex.load_screen_textures('result')
self.textures = load_all_textures_from_zip(zip_file)
def load_sounds(self): def load_sounds(self):
sounds_dir = Path("Sounds") sounds_dir = Path("Sounds")
@@ -46,11 +43,11 @@ class ResultScreen:
self.load_textures() self.load_textures()
self.load_sounds() self.load_sounds()
self.screen_init = True self.screen_init = True
self.song_info = OutlinedText(session_data.song_title, 40, ray.Color(255, 255, 255, 255), ray.Color(0, 0, 0, 255), outline_thickness=5) self.song_info = OutlinedText(session_data.song_title, 40, ray.WHITE, ray.BLACK, outline_thickness=5)
audio.play_sound(self.bgm) audio.play_sound(self.bgm)
self.fade_in = FadeIn() self.fade_in = FadeIn()
self.fade_out = None self.fade_out = tex.get_animation(0)
self.fade_in_bottom = None self.fade_in_bottom = tex.get_animation(1)
self.gauge = None self.gauge = None
self.score_delay = None self.score_delay = None
self.bottom_characters = BottomCharacters() self.bottom_characters = BottomCharacters()
@@ -73,21 +70,19 @@ class ResultScreen:
self.is_skipped = False self.is_skipped = False
self.start_ms = get_current_ms() self.start_ms = get_current_ms()
if session_data.result_bad == 0: if session_data.result_bad == 0:
self.crown_texture = 125 self.crown_type = 'crown_fc'
else: else:
self.crown_texture = 124 self.crown_type = 'crown_clear'
def on_screen_end(self): def on_screen_end(self):
self.screen_init = False self.screen_init = False
global_data.songs_played += 1 global_data.songs_played += 1
for zip in self.textures: tex.unload_textures()
for texture in self.textures[zip]:
ray.unload_texture(texture)
audio.stop_sound(self.bgm) audio.stop_sound(self.bgm)
utils.session_data = utils.reset_session() utils.session_data = utils.reset_session()
return "SONG_SELECT" return "SONG_SELECT"
def update_score_animation(self, is_skipped): def update_score_animation(self):
if self.is_skipped: if self.is_skipped:
setattr(self, self.update_list[self.update_index][0], self.update_list[self.update_index][1]) setattr(self, self.update_list[self.update_index][0], self.update_list[self.update_index][1])
if self.update_index == len(self.update_list) - 1: if self.update_index == len(self.update_list) - 1:
@@ -115,18 +110,16 @@ class ResultScreen:
if not self.is_skipped: if not self.is_skipped:
self.is_skipped = True self.is_skipped = True
else: else:
if self.fade_out is None: self.fade_out.start()
self.fade_out = FadeOut()
audio.play_sound(self.sound_don) audio.play_sound(self.sound_don)
def update(self): def update(self):
self.on_screen_start() self.on_screen_start()
if self.fade_in is not None: self.fade_in.update(get_current_ms())
self.fade_in.update(get_current_ms()) if self.fade_in.is_finished and self.gauge is None:
if self.fade_in.is_finished and self.gauge is None: self.gauge = Gauge(session_data.result_gauge_length)
self.gauge = Gauge(get_current_ms(), session_data.result_gauge_length) self.bottom_characters.start()
self.bottom_characters.start()
self.bottom_characters.update(self.state) self.bottom_characters.update(self.state)
@@ -140,28 +133,24 @@ class ResultScreen:
self.score_delay = get_current_ms() + 1883 self.score_delay = get_current_ms() + 1883
if self.score_delay is not None: if self.score_delay is not None:
if get_current_ms() > self.score_delay and self.fade_in_bottom is None: if get_current_ms() > self.score_delay and not self.fade_in_bottom.is_started:
self.fade_in_bottom = Animation.create_fade(333, initial_opacity=0.0, final_opacity=1.0)
self.fade_in_bottom.start() self.fade_in_bottom.start()
if self.gauge is not None: if self.gauge is not None:
self.state = self.gauge.state self.state = self.gauge.state
self.fade_in_bottom.update(get_current_ms())
if self.fade_in_bottom is not None: alpha_loc = ray.get_shader_location(self.alpha_shader, "ext_alpha")
self.fade_in_bottom.update(get_current_ms()) alpha_value = ray.ffi.new('float*', self.fade_in_bottom.attribute)
alpha_loc = ray.get_shader_location(self.alpha_shader, "ext_alpha") ray.set_shader_value(self.alpha_shader, alpha_loc, alpha_value, SHADER_UNIFORM_FLOAT)
alpha_value = ray.ffi.new('float*', self.fade_in_bottom.attribute)
ray.set_shader_value(self.alpha_shader, alpha_loc, alpha_value, SHADER_UNIFORM_FLOAT)
if get_current_ms() >= self.start_ms + 5000: if get_current_ms() >= self.start_ms + 5000:
self.handle_input() self.handle_input()
self.update_score_animation(self.is_skipped) self.update_score_animation()
if self.fade_out is not None: self.fade_out.update(get_current_ms())
self.fade_out.update(get_current_ms()) if self.fade_out.is_finished:
if self.fade_out.is_finished: return self.on_screen_end()
return self.on_screen_end()
if self.crown is not None: if self.crown is not None:
self.crown.update(get_current_ms()) self.crown.update(get_current_ms())
@@ -169,104 +158,88 @@ class ResultScreen:
def draw_score_info(self): def draw_score_info(self):
if self.good > -1: if self.good > -1:
for i in range(len(str(self.good))): for i in range(len(str(self.good))):
ray.draw_texture(self.textures['result'][int(str(self.good)[::-1][i]) + 136], 943-(i*24), 186, ray.WHITE) tex.draw_texture('score', 'judge_num', frame=int(str(self.good)[::-1][i]), x=943-(i*24), y=186)
if self.ok > -1: if self.ok > -1:
for i in range(len(str(self.ok))): for i in range(len(str(self.ok))):
ray.draw_texture(self.textures['result'][int(str(self.ok)[::-1][i]) + 136], 943-(i*24), 227, ray.WHITE) tex.draw_texture('score', 'judge_num', frame=int(str(self.ok)[::-1][i]), x=943-(i*24), y=227)
if self.bad > -1: if self.bad > -1:
for i in range(len(str(self.bad))): for i in range(len(str(self.bad))):
ray.draw_texture(self.textures['result'][int(str(self.bad)[::-1][i]) + 136], 943-(i*24), 267, ray.WHITE) tex.draw_texture('score', 'judge_num', frame=int(str(self.bad)[::-1][i]), x=943-(i*24), y=267)
if self.max_combo > -1: if self.max_combo > -1:
for i in range(len(str(self.max_combo))): for i in range(len(str(self.max_combo))):
ray.draw_texture(self.textures['result'][int(str(self.max_combo)[::-1][i]) + 136], 1217-(i*24), 227, ray.WHITE) tex.draw_texture('score', 'judge_num', frame=int(str(self.max_combo)[::-1][i]), x=1217-(i*24), y=227)
if self.total_drumroll > -1: if self.total_drumroll > -1:
for i in range(len(str(self.total_drumroll))): for i in range(len(str(self.total_drumroll))):
ray.draw_texture(self.textures['result'][int(str(self.total_drumroll)[::-1][i]) + 136], 1217-(i*24), 186, ray.WHITE) tex.draw_texture('score', 'judge_num', frame=int(str(self.total_drumroll)[::-1][i]), x=1217-(i*24), y=186)
def draw_total_score(self): def draw_total_score(self):
if self.fade_in is None:
return
if not self.fade_in.is_finished: if not self.fade_in.is_finished:
return return
ray.draw_texture(self.textures['result'][167], 554, 236, ray.WHITE) tex.draw_texture('score', 'score_shinuchi')
if self.score > -1: if self.score > -1:
for i in range(len(str(self.score))): for i in range(len(str(self.score))):
ray.draw_texture(self.textures['result'][int(str(self.score)[::-1][i]) + 156], 723-(i*21), 252, ray.WHITE) tex.draw_texture('score', 'score_num', x=-(i*21), frame=int(str(self.score)[::-1][i]))
def draw_bottom_textures(self): def draw_bottom_textures(self):
if self.fade_in_bottom is not None: if self.state == State.FAIL:
src = ray.Rectangle(0, 0, self.textures['result'][328].width, self.textures['result'][328].height) tex.draw_texture('background', 'gradient_fail', color=ray.fade(ray.WHITE, min(0.4, self.fade_in_bottom.attribute)))
if self.state == State.FAIL: else:
dest = ray.Rectangle(0, self.height//2, self.width, self.height//2) ray.begin_shader_mode(self.alpha_shader)
ray.draw_texture_pro(self.textures['result'][329], src, dest, ray.Vector2(0, 0), 0, ray.fade(ray.WHITE, min(0.4, self.fade_in_bottom.attribute))) tex.draw_texture('background', 'gradient_clear', color=ray.fade(ray.WHITE, self.fade_in_bottom.attribute))
else: ray.end_shader_mode()
dest = ray.Rectangle(0, self.height//2 - 72, self.width, self.height//2) self.bottom_characters.draw()
ray.begin_shader_mode(self.alpha_shader)
ray.draw_texture_pro(self.textures['result'][328], src, dest, ray.Vector2(0, 0), 0, ray.fade(ray.WHITE, self.fade_in_bottom.attribute))
ray.end_shader_mode()
self.bottom_characters.draw(self.textures['result'])
def draw(self): def draw(self):
x = 0 x = 0
while x < self.width: while x < self.width:
ray.draw_texture(self.textures['result'][326], x, 0 - self.textures['result'][326].height//2, ray.WHITE) tex.draw_texture('background', 'background_1p', x=x, y=-360)
ray.draw_texture(self.textures['result'][326], x, self.height - self.textures['result'][326].height//2, ray.WHITE) tex.draw_texture('background', 'background_1p', x=x, y=360)
x += self.textures['result'][326].width tex.draw_texture('background', 'footer_1p', x=x, y=-77)
x = 0 tex.draw_texture('background', 'footer_1p', x=x, y=653)
while x < self.width: x += 256
ray.draw_texture(self.textures['result'][327], x, 0 - self.textures['result'][327].height//2, ray.WHITE)
ray.draw_texture(self.textures['result'][327], x, self.height - self.textures['result'][327].height + self.textures['result'][327].height//2, ray.WHITE)
x += self.textures['result'][327].width
ray.draw_texture(self.textures['result'][330], -5, 3, ray.WHITE) tex.draw_texture('background', 'result_text')
ray.draw_texture(self.textures['result'][(global_data.songs_played % 4) + 331], 232, 4, ray.WHITE) tex.draw_texture('song_info', 'song_num', frame=global_data.songs_played%4)
src = ray.Rectangle(0, 0, self.song_info.texture.width, self.song_info.texture.height)
dest = ray.Rectangle(1252 - self.song_info.texture.width, 35 - self.song_info.texture.height / 2, self.song_info.texture.width, self.song_info.texture.height) dest = ray.Rectangle(1252 - self.song_info.texture.width, 35 - self.song_info.texture.height / 2, self.song_info.texture.width, self.song_info.texture.height)
self.song_info.draw(src, dest, ray.Vector2(0, 0), 0, ray.WHITE) self.song_info.draw(self.song_info.default_src, dest, ray.Vector2(0, 0), 0, ray.WHITE)
ray.draw_texture(self.textures['result'][175], 532, 98, ray.fade(ray.WHITE, 0.75)) tex.draw_texture('score', 'overlay', color=ray.fade(ray.WHITE, 0.75))
tex.draw_texture('score', 'difficulty', frame=session_data.selected_difficulty)
ray.draw_texture(self.textures['result'][233 + session_data.selected_difficulty], 289, 129, ray.WHITE)
self.draw_bottom_textures() self.draw_bottom_textures()
if self.gauge is not None: if self.gauge is not None:
self.gauge.draw(self.textures['result']) self.gauge.draw()
ray.draw_texture(self.textures['result'][170], 817, 186, ray.WHITE) tex.draw_texture('score', 'judge_good')
ray.draw_texture(self.textures['result'][171], 817, 227, ray.WHITE) tex.draw_texture('score', 'judge_ok')
ray.draw_texture(self.textures['result'][172], 817, 267, ray.WHITE) tex.draw_texture('score', 'judge_bad')
ray.draw_texture(self.textures['result'][173], 987, 186, ray.WHITE) tex.draw_texture('score', 'max_combo')
ray.draw_texture(self.textures['result'][174], 981, 227, ray.WHITE) tex.draw_texture('score', 'drumroll')
self.draw_score_info() self.draw_score_info()
self.draw_total_score() self.draw_total_score()
if self.crown is not None: if self.crown is not None:
self.crown.draw(self.textures['result'], self.crown_texture) self.crown.draw(self.crown_type)
if self.fade_in is not None: self.fade_in.draw()
self.fade_in.draw(self.width, self.height, self.textures['result'][326], self.textures['result'][327]) ray.draw_rectangle(0, 0, self.width, self.height, ray.fade(ray.BLACK, self.fade_out.attribute))
if self.fade_out is not None:
self.fade_out.draw(self.width, self.height)
def draw_3d(self): def draw_3d(self):
pass pass
class Crown: class Crown:
def __init__(self): def __init__(self):
duration = 466 self.resize = tex.get_animation(2)
self.resize = Animation.create_texture_resize(duration, initial_size=3.5, final_size=0.90, ease_in='quadratic') self.resize_fix = tex.get_animation(3)
self.white_fadein = tex.get_animation(4)
self.gleam = tex.get_animation(5)
self.fadein = tex.get_animation(6)
self.resize.start() self.resize.start()
self.resize_fix = Animation.create_texture_resize(216, initial_size=self.resize.final_size, final_size=1.0, delay=self.resize.duration)
self.resize_fix.start() self.resize_fix.start()
self.white_fadein = Animation.create_fade(133, initial_opacity=0.0, final_opacity=1.0, delay=self.resize.duration + self.resize_fix.duration, reverse_delay=0)
self.white_fadein.start() self.white_fadein.start()
self.gleam = Animation.create_texture_change(400, textures=[(0, 200, 0), (200, 250, 127), (250, 300, 128), (300, 350, 129), (350, 400, 0)], delay=self.resize.duration + self.resize_fix.duration + self.white_fadein.duration)
self.gleam.start() self.gleam.start()
self.fadein = Animation.create_fade(duration, initial_opacity=0.0, final_opacity=1.0, ease_in='quadratic')
self.fadein.start() self.fadein.start()
self.sound = audio.load_sound(Path('Sounds/result/SE_RESULT [1].ogg')) self.sound = audio.load_sound(Path('Sounds/result/SE_RESULT [1].ogg'))
self.sound_played = False self.sound_played = False
@@ -281,87 +254,70 @@ class Crown:
audio.play_sound(self.sound) audio.play_sound(self.sound)
self.sound_played = True self.sound_played = True
def draw(self, textures: list[ray.Texture], crown_index: int): def draw(self, crown_name: str):
scale = self.resize.attribute scale = self.resize.attribute
if self.resize.is_finished: if self.resize.is_finished:
scale = self.resize_fix.attribute scale = self.resize_fix.attribute
texture = textures[crown_index] tex.draw_texture('crown', crown_name, scale=scale, center=True)
x_x = 335 + (texture.width//2) - ((texture.width * scale)//2) tex.draw_texture('crown', 'crown_fade', color=ray.fade(ray.WHITE, self.white_fadein.attribute))
x_y = 150 + (texture.height//2) - ((texture.height * scale)//2) if self.gleam.attribute >= 0:
x_source = ray.Rectangle(0, 0, texture.width, texture.height) tex.draw_texture('crown', 'gleam', frame=self.gleam.attribute)
x_dest = ray.Rectangle(x_x, x_y, texture.width*scale, texture.height*scale)
ray.draw_texture_pro(texture, x_source, x_dest, ray.Vector2(0,0), 0, ray.fade(ray.WHITE, self.fadein.attribute))
ray.draw_texture(textures[126], int(x_x), int(x_y), ray.fade(ray.WHITE, self.white_fadein.attribute))
if self.gleam.attribute != 0:
ray.draw_texture(textures[self.gleam.attribute], int(x_x), int(x_y), ray.WHITE)
class BottomCharacters: class BottomCharacters:
def __init__(self): def __init__(self):
self.move_up = None self.move_up = tex.get_animation(7)
self.move_down = None self.move_down = tex.get_animation(8)
self.move_center = None self.bounce_up = tex.get_animation(9)
self.bounce_up = None self.bounce_down = tex.get_animation(10)
self.bounce_down = None self.move_center = tex.get_animation(11)
self.flower_up = None self.c_bounce_up = tex.get_animation(12)
self.c_bounce_down = tex.get_animation(13)
self.flower_up = tex.get_animation(14)
self.state = None self.state = None
self.flower_index = 341 self.flower_index = 0
self.flower_start = None self.flower_start = None
self.char_1_index = 339 self.chara_0_index = 0
self.char_2_index = 340 self.chara_1_index = 0
self.c_bounce_up = Animation.create_move(266, total_distance=40, ease_in='quadratic')
self.c_bounce_up.start()
self.c_bounce_down = Animation.create_move(266, total_distance=40, ease_out='quadratic', delay=self.c_bounce_up.duration)
self.c_bounce_down.start()
self.is_finished = False self.is_finished = False
def start(self): def start(self):
self.move_up = Animation.create_move(366, total_distance=380, ease_out='cubic')
self.move_up.start() self.move_up.start()
self.move_down = Animation.create_move(133, total_distance=30, ease_out='cubic', delay=self.move_up.duration-5)
self.move_down.start() self.move_down.start()
self.c_bounce_up.start()
self.c_bounce_down.start()
def update(self, state): def update(self, state):
self.state = state self.state = state
if self.state == State.CLEAR or self.state == State.RAINBOW: if self.state == State.CLEAR or self.state == State.RAINBOW:
self.char_1_index = 345 self.chara_0_index = 1
self.char_2_index = 346 self.chara_1_index = 1
if self.bounce_up is None: if not self.bounce_up.is_started:
self.bounce_up = Animation.create_move(266, total_distance=40, ease_in='quadratic')
self.bounce_up.start() self.bounce_up.start()
self.bounce_down = Animation.create_move(266, total_distance=40, ease_out='quadratic', delay=self.bounce_up.duration)
self.bounce_down.start() self.bounce_down.start()
self.move_center = Animation.create_move(266, total_distance=450, ease_out='quadratic', delay=self.bounce_down.duration+self.bounce_up.duration)
self.move_center.start() self.move_center.start()
if self.flower_up is None: if self.flower_start is None:
self.flower_up = Animation.create_move(333, total_distance=365, ease_out='quadratic')
self.flower_up.start() self.flower_up.start()
self.flower_start = get_current_ms() self.flower_start = get_current_ms()
elif self.state == State.FAIL: elif self.state == State.FAIL:
self.char_1_index = 347 self.chara_0_index = 2
self.char_2_index = 348 self.chara_1_index = 2
if self.move_up is not None: self.move_up.update(get_current_ms())
self.move_up.update(get_current_ms()) self.move_down.update(get_current_ms())
if self.move_down is not None: self.is_finished = self.move_down.is_finished
self.move_down.update(get_current_ms()) self.bounce_up.update(get_current_ms())
self.is_finished = self.move_down.is_finished self.bounce_down.update(get_current_ms())
if self.bounce_up is not None: if self.bounce_down.is_finished:
self.bounce_up.update(get_current_ms()) self.bounce_up.restart()
if self.bounce_down is not None: self.bounce_down.restart()
self.bounce_down.update(get_current_ms()) self.move_center.update(get_current_ms())
if self.bounce_down.is_finished and self.bounce_up is not None: self.flower_up.update(get_current_ms())
self.bounce_up.restart()
self.bounce_down.restart()
if self.move_center is not None:
self.move_center.update(get_current_ms())
if self.flower_up is not None:
self.flower_up.update(get_current_ms())
if self.flower_start is not None: if self.flower_start is not None:
if get_current_ms() > self.flower_start + 116*2 + 333: if get_current_ms() > self.flower_start + 116*2 + 333:
self.flower_index = 343 self.flower_index = 2
elif get_current_ms() > self.flower_start + 116 + 333: elif get_current_ms() > self.flower_start + 116 + 333:
self.flower_index = 342 self.flower_index = 1
self.c_bounce_up.update(get_current_ms()) self.c_bounce_up.update(get_current_ms())
self.c_bounce_down.update(get_current_ms()) self.c_bounce_down.update(get_current_ms())
@@ -369,61 +325,45 @@ class BottomCharacters:
self.c_bounce_up.restart() self.c_bounce_up.restart()
self.c_bounce_down.restart() self.c_bounce_down.restart()
def draw_flowers(self, textures: list[ray.Texture]): def draw_flowers(self):
if self.flower_up is None: tex.draw_texture('bottom','flowers', y=-self.flower_up.attribute, frame=self.flower_index)
return tex.draw_texture('bottom','flowers', y=-self.flower_up.attribute, frame=self.flower_index, x=792, mirror='horizontal')
y = 720+textures[self.flower_index].height - int(self.flower_up.attribute)
source_rect = ray.Rectangle(0, 0, textures[self.flower_index].width, textures[self.flower_index].height)
dest_rect = ray.Rectangle(1280-textures[self.flower_index].width, y, textures[self.flower_index].width, textures[self.flower_index].height)
source_rect.width = -textures[self.flower_index].width
ray.draw_texture_pro(textures[self.flower_index], source_rect, dest_rect, ray.Vector2(0, 0), 0, ray.WHITE)
ray.draw_texture(textures[self.flower_index], 0, y, ray.WHITE)
def draw(self, textures: list[ray.Texture]): def draw(self):
if self.move_up is None or self.move_down is None: self.draw_flowers()
return
self.draw_flowers(textures) y = -self.move_up.attribute + self.move_down.attribute + self.bounce_up.attribute - self.bounce_down.attribute
if self.state == State.RAINBOW:
center_y = self.c_bounce_up.attribute - self.c_bounce_down.attribute
tex.draw_texture('bottom', 'chara_center', y=-self.move_center.attribute + center_y)
y = 720 - int(self.move_up.attribute) + int(self.move_down.attribute) tex.draw_texture('bottom', 'chara_0', frame=self.chara_0_index, y=y)
if self.bounce_up is not None and self.bounce_down is not None: tex.draw_texture('bottom', 'chara_1', frame=self.chara_1_index, y=y)
y = 720 - int(self.move_up.attribute) + int(self.move_down.attribute) + int(self.bounce_up.attribute) - int(self.bounce_down.attribute)
if self.state == State.RAINBOW and self.move_center is not None:
center_y = int(self.c_bounce_up.attribute) - int(self.c_bounce_down.attribute)
ray.draw_texture(textures[344], 1280//2 - textures[344].width//2, (800 - int(self.move_center.attribute)) + int(center_y), ray.WHITE)
ray.draw_texture(textures[self.char_1_index], 125, y, ray.WHITE)
ray.draw_texture(textures[self.char_2_index], 820, y, ray.WHITE)
class FadeIn: class FadeIn:
def __init__(self): def __init__(self):
self.fadein = Animation.create_fade(450, initial_opacity=1.0, final_opacity=0.0, delay=100) self.fadein = tex.get_animation(15)
self.fadein.start() self.fadein.start()
self.fade = ray.fade(ray.WHITE, self.fadein.attribute)
self.is_finished = False self.is_finished = False
def update(self, current_ms: float): def update(self, current_ms: float):
self.fadein.update(current_ms) self.fadein.update(current_ms)
self.fade = ray.fade(ray.WHITE, self.fadein.attribute)
self.is_finished = self.fadein.is_finished self.is_finished = self.fadein.is_finished
def draw(self, screen_width: int, screen_height: int, texture_1: ray.Texture, texture_2: ray.Texture): def draw(self):
x = 0 x = 0
while x < screen_width: color = ray.fade(ray.WHITE, self.fadein.attribute)
ray.draw_texture(texture_1, x, 0 - texture_1.height//2, self.fade) while x < 1280:
ray.draw_texture(texture_1, x, screen_height - texture_1.height//2, self.fade) tex.draw_texture('background', 'background_1p', x=x, y=-360, color=color)
x += texture_1.width tex.draw_texture('background', 'background_1p', x=x, y=360, color=color)
x = 0 tex.draw_texture('background', 'footer_1p', x=x, y=-77, color=color)
while x < screen_width: tex.draw_texture('background', 'footer_1p', x=x, y=653, color=color)
ray.draw_texture(texture_2, x, 0 - texture_2.height//2, self.fade) x += 256
ray.draw_texture(texture_2, x, screen_height - texture_2.height + texture_2.height//2, self.fade)
x += texture_2.width
class ScoreAnimator: class ScoreAnimator:
def __init__(self, target_score): def __init__(self, target_score):
self.target_score = str(target_score) self.target_score = str(target_score)
self.current_score_list = [[0,0] for i in range(len(self.target_score))] self.current_score_list = [[0,0] for _ in range(len(self.target_score))]
self.digit_index = len(self.target_score) - 1 self.digit_index = len(self.target_score) - 1
self.is_finished = False self.is_finished = False
@@ -441,10 +381,11 @@ class ScoreAnimator:
return int(''.join([str(item[0]) for item in self.current_score_list])) return int(''.join([str(item[0]) for item in self.current_score_list]))
class Gauge: class Gauge:
def __init__(self, current_ms: float, gauge_length): def __init__(self, gauge_length):
self.gauge_length = gauge_length self.gauge_length = gauge_length
self.rainbow_animation = None self.rainbow_animation = tex.get_animation(16)
self.gauge_fade_in = Animation.create_fade(366, initial_opacity=0.0, final_opacity=1.0) self.gauge_fade_in = tex.get_animation(17)
self.rainbow_animation.start()
self.gauge_fade_in.start() self.gauge_fade_in.start()
self.is_finished = self.gauge_fade_in.is_finished self.is_finished = self.gauge_fade_in.is_finished
if self.gauge_length == 87: if self.gauge_length == 87:
@@ -454,69 +395,43 @@ class Gauge:
else: else:
self.state = State.FAIL self.state = State.FAIL
def _create_rainbow_anim(self, current_ms):
anim = Animation.create_texture_change((16.67*8) * 3, textures=[((16.67 * 3) * i, (16.67 * 3) * (i + 1), i) for i in range(8)])
anim.start()
return anim
def _create_anim(self, current_ms: float, init: float, final: float):
anim = Animation.create_fade(450, initial_opacity=init, final_opacity=final)
anim.start()
return anim
def update(self, current_ms: float): def update(self, current_ms: float):
if self.rainbow_animation is None: self.rainbow_animation.update(current_ms)
self.rainbow_animation = self._create_rainbow_anim(current_ms) if self.rainbow_animation.is_finished:
else: self.rainbow_animation.restart()
self.rainbow_animation.update(current_ms)
if self.rainbow_animation.is_finished:
self.rainbow_animation = None
self.gauge_fade_in.update(current_ms) self.gauge_fade_in.update(current_ms)
self.is_finished = self.gauge_fade_in.is_finished self.is_finished = self.gauge_fade_in.is_finished
def draw(self, textures: list[ray.Texture]): def draw(self):
color = ray.fade(ray.WHITE, self.gauge_fade_in.attribute) color = ray.fade(ray.WHITE, self.gauge_fade_in.attribute)
draw_scaled_texture(textures[217], 554, 109, (10/11), color) scale = 10/11
tex.draw_texture('gauge', 'unfilled', scale=scale, color=color)
gauge_length = int(self.gauge_length) gauge_length = int(self.gauge_length)
if gauge_length == 87 and self.rainbow_animation is not None: if gauge_length == 87:
if 0 < self.rainbow_animation.attribute < 8: if 0 < self.rainbow_animation.attribute < 8:
draw_scaled_texture(textures[217 + int(self.rainbow_animation.attribute)], 554, 109, (10/11), color) tex.draw_texture('gauge', 'rainbow', frame=self.rainbow_animation.attribute-1, scale=scale, color=color)
draw_scaled_texture(textures[218 + int(self.rainbow_animation.attribute)], 554, 109, (10/11), color) tex.draw_texture('gauge', 'rainbow', frame=self.rainbow_animation.attribute, scale=scale, color=color)
else: else:
for i in range(gauge_length+1): for i in range(gauge_length+1):
width = int(i * 7.2) width = int(i * 7.2)
if i == 69: if i == 69:
draw_scaled_texture(textures[192], 562 + width, 142 - 22, (10/11), color) tex.draw_texture('gauge', 'bar_clear_transition', x=width, scale=scale, color=color)
elif i > 69: elif i > 69:
if i % 5 == 0: if i % 5 == 0:
draw_scaled_texture(textures[191], 561 + width, 142 - 20, (10/11), color) tex.draw_texture('gauge', 'bar_clear_top', x=width, scale=scale, color=color)
draw_scaled_texture(textures[196], 561 + width, 142, (10/11), color) tex.draw_texture('gauge', 'bar_clear_bottom', x=width, scale=scale, color=color)
draw_scaled_texture(textures[191], 562 + width, 142 - 20, (10/11), color) tex.draw_texture('gauge', 'bar_clear_top', x=width+1, scale=scale, color=color)
draw_scaled_texture(textures[196], 562 + width, 142, (10/11), color) tex.draw_texture('gauge', 'bar_clear_bottom', x=width+1, scale=scale, color=color)
else: else:
if i % 5 == 0: if i % 5 == 0:
draw_scaled_texture(textures[189], 561 + width, 142, (10/11), color) tex.draw_texture('gauge', 'bar', x=width, scale=scale, color=color)
draw_scaled_texture(textures[189], 562 + width, 142, (10/11), color) tex.draw_texture('gauge', 'bar', x=width+1, scale=scale, color=color)
draw_scaled_texture(textures[226], 554, 109, (10/11), ray.fade(ray.WHITE, min(0.15, self.gauge_fade_in.attribute))) tex.draw_texture('gauge', 'overlay', scale=scale, color=ray.fade(ray.WHITE, min(0.15, self.gauge_fade_in.attribute)))
draw_scaled_texture(textures[176], 1185, 116, (10/11), color) tex.draw_texture('gauge', 'footer', scale=scale, color=color)
if gauge_length >= 69: if gauge_length >= 69:
draw_scaled_texture(textures[194], 1058, 124, (10/11), color) tex.draw_texture('gauge', 'clear', scale=scale, color=color)
draw_scaled_texture(textures[195], 1182, 115, (10/11), color) tex.draw_texture('gauge', 'tamashii', scale=scale, color=color)
else: else:
draw_scaled_texture(textures[187], 1058, 124, (10/11), color) tex.draw_texture('gauge', 'clear_dark', scale=scale, color=color)
draw_scaled_texture(textures[188], 1182, 115, (10/11), color) tex.draw_texture('gauge', 'tamashii_dark', scale=scale, color=color)
class FadeOut:
def __init__(self) -> None:
self.texture = global_data.textures['scene_change_fade'][0]
self.fade_out = Animation.create_fade(1000, initial_opacity=0.0, final_opacity=1.0)
self.fade_out.start()
self.is_finished = False
def update(self, current_time_ms: float):
self.fade_out.update(current_time_ms)
self.is_finished = self.fade_out.is_finished
def draw(self, screen_width: int, screen_height: int):
src = ray.Rectangle(0, 0, self.texture.width, self.texture.height)
dst = ray.Rectangle(0, 0, screen_width, screen_height)
ray.draw_texture_pro(self.texture, src, dst, ray.Vector2(0,0), 0, ray.fade(ray.WHITE, self.fade_out.attribute))