deworming my simulator

This commit is contained in:
Yonokid
2025-08-28 20:50:53 -04:00
parent 9da7ce7b95
commit 2bf7495020
13 changed files with 257 additions and 382 deletions

View File

@@ -88,14 +88,14 @@ def main():
create_song_db()
title_screen = TitleScreen(screen_width, screen_height)
entry_screen = EntryScreen(screen_width, screen_height)
song_select_screen = SongSelectScreen(screen_width, screen_height)
load_screen = LoadScreen(screen_width, screen_height, song_select_screen)
game_screen = GameScreen(screen_width, screen_height)
result_screen = ResultScreen(screen_width, screen_height)
settings_screen = SettingsScreen(screen_width, screen_height)
dev_screen = DevScreen(screen_width, screen_height)
title_screen = TitleScreen()
entry_screen = EntryScreen()
song_select_screen = SongSelectScreen()
load_screen = LoadScreen(song_select_screen)
game_screen = GameScreen()
result_screen = ResultScreen()
settings_screen = SettingsScreen()
dev_screen = DevScreen()
screen_mapping = {
Screens.ENTRY: entry_screen,

View File

@@ -15,7 +15,7 @@ def get_current_ms() -> int:
class BaseAnimation():
def __init__(self, duration: float, delay: float = 0.0) -> None:
def __init__(self, duration: float, delay: float = 0.0, loop: bool = False) -> None:
"""
Initialize a base animation.
@@ -31,6 +31,7 @@ class BaseAnimation():
self.is_finished = False
self.attribute = 0
self.is_started = False
self.loop = loop
def __repr__(self):
return str(self.__dict__)
@@ -40,6 +41,8 @@ class BaseAnimation():
def update(self, current_time_ms: float) -> None:
"""Update the animation based on the current time."""
if self.loop and self.is_finished:
self.restart()
def restart(self) -> None:
self.start_ms = get_current_ms()
@@ -87,11 +90,11 @@ class BaseAnimation():
return progress
class FadeAnimation(BaseAnimation):
def __init__(self, duration: float, initial_opacity: float = 1.0,
def __init__(self, duration: float, initial_opacity: float = 1.0, loop: bool = False,
final_opacity: float = 0.0, delay: float = 0.0,
ease_in: Optional[str] = None, ease_out: Optional[str] = None,
reverse_delay: Optional[float] = None) -> None:
super().__init__(duration, delay)
super().__init__(duration, delay=delay, loop=loop)
self.initial_opacity = initial_opacity
self.attribute = initial_opacity
self.final_opacity = final_opacity
@@ -112,6 +115,7 @@ class FadeAnimation(BaseAnimation):
def update(self, current_time_ms: float) -> None:
if not self.is_started:
return
super().update(current_time_ms)
elapsed_time = current_time_ms - self.start_ms
if elapsed_time <= self.delay:
@@ -134,11 +138,11 @@ class FadeAnimation(BaseAnimation):
self.attribute = self.initial_opacity + progress * (self.final_opacity - self.initial_opacity)
class MoveAnimation(BaseAnimation):
def __init__(self, duration: float, total_distance: int = 0,
def __init__(self, duration: float, total_distance: int = 0, loop: bool = False,
start_position: int = 0, delay: float = 0.0,
reverse_delay: Optional[float] = None,
ease_in: Optional[str] = None, ease_out: Optional[str] = None) -> None:
super().__init__(duration, delay)
super().__init__(duration, delay=delay, loop=loop)
self.reverse_delay = reverse_delay
self.reverse_delay_saved = reverse_delay
self.total_distance = total_distance
@@ -158,6 +162,7 @@ class MoveAnimation(BaseAnimation):
def update(self, current_time_ms: float) -> None:
if not self.is_started:
return
super().update(current_time_ms)
elapsed_time = current_time_ms - self.start_ms
if elapsed_time < self.delay:
self.attribute = self.start_position
@@ -178,8 +183,9 @@ class MoveAnimation(BaseAnimation):
self.attribute = self.start_position + (self.total_distance * progress)
class TextureChangeAnimation(BaseAnimation):
def __init__(self, duration: float, textures: list[tuple[float, float, int]], delay: float = 0.0) -> None:
super().__init__(duration)
def __init__(self, duration: float, textures: list[tuple[float, float, int]],
loop: bool = False, delay: float = 0.0) -> None:
super().__init__(duration, loop=loop)
self.textures = textures
self.delay = delay
self.delay_saved = delay
@@ -190,9 +196,9 @@ class TextureChangeAnimation(BaseAnimation):
self.attribute = self.textures[0][2]
def update(self, current_time_ms: float) -> None:
super().update(current_time_ms)
if not self.is_started:
return
super().update(current_time_ms)
elapsed_time = current_time_ms - self.start_ms
if elapsed_time < self.delay:
return
@@ -206,11 +212,12 @@ class TextureChangeAnimation(BaseAnimation):
self.is_finished = True
class TextStretchAnimation(BaseAnimation):
def __init__(self, duration: float) -> None:
super().__init__(duration)
def __init__(self, duration: float, loop: bool = False,) -> None:
super().__init__(duration, loop=loop)
def update(self, current_time_ms: float) -> None:
if not self.is_started:
return
super().update(current_time_ms)
elapsed_time = current_time_ms - self.start_ms
if elapsed_time <= self.duration:
self.attribute = 2 + 5 * (elapsed_time // 25)
@@ -223,10 +230,11 @@ class TextStretchAnimation(BaseAnimation):
class TextureResizeAnimation(BaseAnimation):
def __init__(self, duration: float, initial_size: float = 1.0,
loop: bool = False,
final_size: float = 0.0, delay: float = 0.0,
reverse_delay: Optional[float] = None,
ease_in: Optional[str] = None, ease_out: Optional[str] = None) -> None:
super().__init__(duration, delay)
super().__init__(duration, delay=delay, loop=loop)
self.initial_size = initial_size
self.final_size = final_size
self.reverse_delay = reverse_delay
@@ -249,6 +257,7 @@ class TextureResizeAnimation(BaseAnimation):
return
else:
self.is_started = not self.is_finished
super().update(current_time_ms)
elapsed_time = current_time_ms - self.start_ms
if elapsed_time <= self.delay:

View File

@@ -1,22 +1,16 @@
import random
from pathlib import Path
import pyray as ray
from libs.animation import Animation
from libs.texture import TextureWrapper
from libs.utils import load_all_textures_from_zip
class Background:
def __init__(self, screen_width: int, screen_height: int, player_num: int):
self.screen_width = screen_width
self.screen_height = screen_height
def __init__(self, player_num: int):
self.tex_wrapper = TextureWrapper()
self.tex_wrapper.load_animations('background')
self.donbg = DonBG.create(self.tex_wrapper, self.screen_width, self.screen_height, random.randint(0, 5), player_num)
self.bg_normal = BGNormal.create(self.screen_width, self.screen_height, random.randint(1, 5))
self.bg_fever = BGFever.create(self.screen_width, self.screen_height, 4)
self.donbg = DonBG.create(self.tex_wrapper, random.randint(0, 5), player_num)
self.bg_normal = BGNormal.create(self.tex_wrapper, random.randint(0, 4))
self.bg_fever = BGFever.create(self.tex_wrapper, 3)
self.footer = Footer(self.tex_wrapper, random.randint(0, 2))
self.is_clear = False
def update(self, current_time_ms: float, is_clear: bool):
@@ -27,9 +21,9 @@ class Background:
self.bg_normal.update(current_time_ms)
self.bg_fever.update(current_time_ms)
def draw(self):
self.bg_normal.draw()
self.bg_normal.draw(self.tex_wrapper)
if self.is_clear:
self.bg_fever.draw()
self.bg_fever.draw(self.tex_wrapper)
self.footer.draw(self.tex_wrapper)
self.donbg.draw(self.tex_wrapper)
@@ -39,19 +33,16 @@ class Background:
class DonBG:
@staticmethod
def create(tex: TextureWrapper, screen_width: int, screen_height: int, index: int, player_num: int):
def create(tex: TextureWrapper, index: int, player_num: int):
map = [DonBG1, DonBG2, DonBG3, DonBG4, DonBG5, DonBG6]
selected_obj = map[index]
return selected_obj(tex, index, screen_width, screen_height, player_num)
return selected_obj(tex, index, player_num)
class DonBGBase:
def __init__(self, tex: TextureWrapper, index: int, screen_width: int, screen_height: int, player_num: int):
self.screen_width = screen_width
self.screen_height = screen_height
def __init__(self, tex: TextureWrapper, index: int, player_num: int):
self.name = f'{index}_{player_num}'
tex.load_zip('background', f'donbg/{self.name}')
self.move = tex.get_animation(0)
self.move.start()
self.is_clear = False
self.clear_fade = tex.get_animation(1)
@@ -61,19 +52,14 @@ class DonBGBase:
self.is_clear = is_clear
self.move.update(current_time_ms)
self.clear_fade.update(current_time_ms)
if self.move.is_finished:
self.move.restart()
class DonBG1(DonBGBase):
def __init__(self, tex: TextureWrapper, index: int, screen_width: int, screen_height: int, player_num: int):
super().__init__(tex, index, screen_width, screen_height, player_num)
def __init__(self, tex: TextureWrapper, index: int, player_num: int):
super().__init__(tex, index, player_num)
self.overlay_move = tex.get_animation(2)
self.overlay_move.start()
def update(self, current_time_ms: float, is_clear: bool):
super().update(current_time_ms, is_clear)
self.overlay_move.update(current_time_ms)
if self.overlay_move.is_finished:
self.overlay_move.restart()
def draw(self, tex: TextureWrapper):
self._draw_textures(tex, 1.0)
if self.is_clear:
@@ -87,15 +73,12 @@ class DonBG1(DonBGBase):
tex.draw_texture(self.name, 'footer', frame=self.is_clear, fade=fade, x=(i*56)+self.move.attribute*((56/328)*3), y=self.overlay_move.attribute)
class DonBG2(DonBGBase):
def __init__(self, tex: TextureWrapper, index: int, screen_width: int, screen_height: int, player_num: int):
super().__init__(tex, index, screen_width, screen_height, player_num)
def __init__(self, tex: TextureWrapper, index: int, player_num: int):
super().__init__(tex, index, player_num)
self.overlay_move = tex.get_animation(3)
self.overlay_move.start()
def update(self, current_time_ms: float, is_clear: bool):
super().update(current_time_ms, is_clear)
self.overlay_move.update(current_time_ms)
if self.overlay_move.is_finished:
self.overlay_move.restart()
def draw(self, tex: TextureWrapper):
self._draw_textures(tex, 1.0)
if self.is_clear:
@@ -106,16 +89,12 @@ class DonBG2(DonBGBase):
tex.draw_texture(self.name, 'overlay', frame=self.is_clear, fade=fade, x=(i*328)+self.move.attribute, y=self.overlay_move.attribute)
class DonBG3(DonBGBase):
def __init__(self, tex: TextureWrapper, index: int, screen_width: int, screen_height: int, player_num: int):
super().__init__(tex, index, screen_width, screen_height, player_num)
def __init__(self, tex: TextureWrapper, index: int, player_num: int):
super().__init__(tex, index, player_num)
self.bounce_up = tex.get_animation(4)
self.bounce_down = tex.get_animation(5)
self.overlay_move = tex.get_animation(6)
self.overlay_move_2 = tex.get_animation(7)
self.bounce_up.start()
self.bounce_down.start()
self.overlay_move.start()
self.overlay_move_2.start()
def update(self, current_time_ms: float, is_clear: bool):
super().update(current_time_ms, is_clear)
@@ -123,11 +102,6 @@ class DonBG3(DonBGBase):
self.bounce_down.update(current_time_ms)
self.overlay_move.update(current_time_ms)
self.overlay_move_2.update(current_time_ms)
if self.overlay_move_2.is_finished:
self.bounce_up.restart()
self.bounce_down.restart()
self.overlay_move.restart()
self.overlay_move_2.restart()
def draw(self, tex: TextureWrapper):
self._draw_textures(tex, 1.0)
@@ -142,15 +116,12 @@ class DonBG3(DonBGBase):
tex.draw_texture(self.name, 'overlay', frame=self.is_clear, fade=fade, x=(i*328)+(self.move.attribute*2), y=y)
class DonBG4(DonBGBase):
def __init__(self, tex: TextureWrapper, index: int, screen_width: int, screen_height: int, player_num: int):
super().__init__(tex, index, screen_width, screen_height, player_num)
def __init__(self, tex: TextureWrapper, index: int, player_num: int):
super().__init__(tex, index, player_num)
self.overlay_move = tex.get_animation(2)
self.overlay_move.start()
def update(self, current_time_ms: float, is_clear: bool):
super().update(current_time_ms, is_clear)
self.overlay_move.update(current_time_ms)
if self.overlay_move.is_finished:
self.overlay_move.restart()
def draw(self, tex: TextureWrapper):
self._draw_textures(tex, 1.0)
if self.is_clear:
@@ -162,24 +133,17 @@ class DonBG4(DonBGBase):
tex.draw_texture(self.name, 'overlay', frame=self.is_clear, fade=fade, x=(i*328)+self.move.attribute, y=self.overlay_move.attribute)
class DonBG5(DonBGBase):
def __init__(self, tex: TextureWrapper, index: int, screen_width: int, screen_height: int, player_num: int):
super().__init__(tex, index, screen_width, screen_height, player_num)
def __init__(self, tex: TextureWrapper, index: int, player_num: int):
super().__init__(tex, index, player_num)
self.bounce_up = tex.get_animation(4)
self.bounce_down = tex.get_animation(5)
self.adjust = tex.get_animation(8)
self.bounce_up.start()
self.bounce_down.start()
self.adjust.start()
def update(self, current_time_ms: float, is_clear: bool):
super().update(current_time_ms, is_clear)
self.bounce_up.update(current_time_ms)
self.bounce_down.update(current_time_ms)
self.adjust.update(current_time_ms)
if self.adjust.is_finished:
self.bounce_up.restart()
self.bounce_down.restart()
self.adjust.restart()
def draw(self, tex: TextureWrapper):
self._draw_textures(tex, 1.0)
@@ -193,15 +157,12 @@ class DonBG5(DonBGBase):
tex.draw_texture(self.name, 'overlay', frame=self.is_clear, fade=fade, x=(i*368)+(self.move.attribute * ((184/328)*2)), y=self.bounce_up.attribute - self.bounce_down.attribute - self.adjust.attribute)
class DonBG6(DonBGBase):
def __init__(self, tex: TextureWrapper, index: int, screen_width: int, screen_height: int, player_num: int):
super().__init__(tex, index, screen_width, screen_height, player_num)
def __init__(self, tex: TextureWrapper, index: int, player_num: int):
super().__init__(tex, index, player_num)
self.overlay_move = tex.get_animation(2)
self.overlay_move.start()
def update(self, current_time_ms: float, is_clear: bool):
super().update(current_time_ms, is_clear)
self.overlay_move.update(current_time_ms)
if self.overlay_move.is_finished:
self.overlay_move.restart()
def draw(self, tex: TextureWrapper):
self._draw_textures(tex, 1.0)
if self.is_clear:
@@ -218,98 +179,71 @@ class DonBG6(DonBGBase):
class BGNormal:
@staticmethod
def create(screen_width: int, screen_height: int, index: int):
map = [None, BGNormal1, BGNormal2, BGNormal3, BGNormal4, BGNormal5]
def create(tex: TextureWrapper, index: int):
map = [BGNormal1, BGNormal2, BGNormal3, BGNormal4, BGNormal5]
selected_obj = map[index]
return selected_obj(index, screen_width, screen_height)
return selected_obj(tex, index)
class BGNormalBase:
def __init__(self, index: int, screen_width: int, screen_height: int):
self.screen_width = screen_width
self.screen_height = screen_height
self.name = 'bg_nomal_a_' + str(index).zfill(2)
self.textures = (load_all_textures_from_zip(Path(f'Graphics/lumendata/enso_original/{self.name}.zip')))
def unload(self):
for texture_group in self.textures:
for texture in self.textures[texture_group]:
ray.unload_texture(texture)
def __init__(self, tex: TextureWrapper, index: int):
self.name = "bg_" + str(index)
tex.load_zip('background', f'bg_normal/{self.name}')
class BGNormal1(BGNormalBase):
def __init__(self, index: int, screen_width: int, screen_height: int):
super().__init__(index, screen_width, screen_height)
self.flicker = Animation.create_fade(16.67*4, initial_opacity=0.5, final_opacity=0.4, reverse_delay=0)
self.flicker.start()
def __init__(self, tex: TextureWrapper, index: int):
super().__init__(tex, index)
self.flicker = tex.get_animation(9)
def update(self, current_time_ms: float):
self.flicker.update(current_time_ms)
if self.flicker.is_finished:
self.flicker.restart()
def draw(self):
ray.draw_texture(self.textures[self.name][0], 0, 360, ray.WHITE)
ray.draw_texture(self.textures[self.name][1], 0, 360, ray.fade(ray.WHITE, self.flicker.attribute))
def draw(self, tex: TextureWrapper):
tex.draw_texture(self.name, 'background')
tex.draw_texture(self.name, 'overlay', fade=self.flicker.attribute)
class BGNormal2(BGNormalBase):
def __init__(self, index: int, screen_width: int, screen_height: int):
super().__init__(index, screen_width, screen_height)
self.flicker = Animation.create_fade(16.67*4, initial_opacity=0.5, final_opacity=0.4, reverse_delay=0)
self.flicker.start()
def __init__(self, tex: TextureWrapper, index: int):
super().__init__(tex, index)
self.flicker = tex.get_animation(9)
def update(self, current_time_ms: float):
self.flicker.update(current_time_ms)
if self.flicker.is_finished:
self.flicker.restart()
def draw(self):
ray.draw_texture(self.textures[self.name][0], 0, 360, ray.WHITE)
ray.draw_texture(self.textures[self.name][1], 0, 360, ray.fade(ray.WHITE, self.flicker.attribute))
def draw(self, tex: TextureWrapper):
tex.draw_texture(self.name, 'background')
tex.draw_texture(self.name, 'overlay', fade=self.flicker.attribute)
class BGNormal3(BGNormalBase):
def __init__(self, index: int, screen_width: int, screen_height: int):
super().__init__(index, screen_width, screen_height)
self.flicker = Animation.create_fade(16.67*10, initial_opacity=0.5, final_opacity=0.4, reverse_delay=0)
self.flicker.start()
def __init__(self, tex: TextureWrapper, index: int):
super().__init__(tex, index)
self.flicker = tex.get_animation(10)
def update(self, current_time_ms):
self.flicker.update(current_time_ms)
if self.flicker.is_finished:
self.flicker.restart()
def draw(self):
src = ray.Rectangle(0, 0, self.textures[self.name][0].width, self.textures[self.name][0].height)
dest = ray.Rectangle(0, 360, self.screen_width, self.textures[self.name][0].height)
ray.draw_texture_pro(self.textures[self.name][0], src, dest, ray.Vector2(0, 0), 0, ray.WHITE)
ray.draw_texture(self.textures[self.name][3], (self.screen_width//2) - (self.textures[self.name][3].width//2), 360, ray.WHITE)
ray.draw_texture(self.textures[self.name][6], 0, 360, ray.WHITE)
def draw(self, tex: TextureWrapper):
tex.draw_texture(self.name, 'background')
tex.draw_texture(self.name, 'center')
tex.draw_texture(self.name, 'overlay')
src = ray.Rectangle(0, 0, -self.textures[self.name][7].width, self.textures[self.name][7].height)
dest = ray.Rectangle((self.screen_width//2) - 170, 490, self.textures[self.name][7].width, self.textures[self.name][7].height)
ray.draw_texture_pro(self.textures[self.name][7], src, dest, ray.Vector2(0, 0), 0, ray.WHITE)
ray.draw_texture(self.textures[self.name][7], (self.screen_width//2) + 50, 490, ray.WHITE)
tex.draw_texture(self.name, 'lamps', index=0)
tex.draw_texture(self.name, 'lamps', index=1, mirror='horizontal')
tex.draw_texture(self.name, 'light_orange', index=0, fade=self.flicker.attribute)
tex.draw_texture(self.name, 'light_orange', index=1, fade=self.flicker.attribute)
tex.draw_texture(self.name, 'light_red', fade=self.flicker.attribute)
tex.draw_texture(self.name, 'light_green', fade=self.flicker.attribute)
tex.draw_texture(self.name, 'light_orange', index=2, fade=self.flicker.attribute)
tex.draw_texture(self.name, 'light_yellow', index=0, fade=self.flicker.attribute)
tex.draw_texture(self.name, 'light_yellow', index=1, fade=self.flicker.attribute)
#Orange
color = ray.fade(ray.WHITE, self.flicker.attribute)
ray.draw_texture(self.textures[self.name][1], (self.screen_width//2) + 180, 300, color)
ray.draw_texture(self.textures[self.name][1], (self.screen_width//2) - 380, 300, color)
#Red Green Orange
ray.draw_texture(self.textures[self.name][2], (self.screen_width//2) - 220, 350, color)
ray.draw_texture(self.textures[self.name][4], (self.screen_width//2) - 100, 350, color)
ray.draw_texture(self.textures[self.name][1], (self.screen_width//2) + 10, 350, color)
#Yellow
ray.draw_texture(self.textures[self.name][5], (self.screen_width//2) - 220, 500, color)
ray.draw_texture(self.textures[self.name][5], (self.screen_width//2) + 10, 500, color)
ray.draw_texture(self.textures[self.name][9], (self.screen_width//2) - 320, 520, ray.WHITE)
ray.draw_texture(self.textures[self.name][10], 100, 360, ray.WHITE)
ray.draw_texture(self.textures[self.name][11], self.screen_width - 100 - self.textures[self.name][11].width, 360, ray.WHITE)
tex.draw_texture(self.name, 'side_l')
tex.draw_texture(self.name, 'side_l_2')
tex.draw_texture(self.name, 'side_r')
class BGNormal4(BGNormalBase):
class Petal:
def __init__(self):
self.spawn_point = self.random_excluding_range()
duration = random.randint(1400, 2000)
self.move_y = Animation.create_move(duration, total_distance=360)
self.move_y.start()
self.move_x = Animation.create_move(duration, total_distance=random.randint(-300, 300))
self.move_y = Animation.create_move(duration, total_distance=360)
self.move_x.start()
self.move_y.start()
def random_excluding_range(self):
while True:
num = random.randint(0, 1280)
@@ -318,150 +252,116 @@ class BGNormal4(BGNormalBase):
def update(self, current_time_ms):
self.move_x.update(current_time_ms)
self.move_y.update(current_time_ms)
def draw(self, texture):
ray.draw_texture(texture, self.spawn_point + int(self.move_x.attribute), 360+int(self.move_y.attribute), ray.fade(ray.WHITE, 0.75))
def __init__(self, index: int, screen_width: int, screen_height: int):
super().__init__(index, screen_width, screen_height)
self.flicker = Animation.create_fade(16.67*3, initial_opacity=0.5, final_opacity=0.4, reverse_delay=0)
self.flicker.start()
self.turtle_move = Animation.create_move(3333*2, start_position=screen_width+112, total_distance=-(screen_width+(112*4)))
self.turtle_move.start()
textures = ((0, 100, 3), (100, 200, 4), (200, 300, 5), (300, 400, 6), (400, 500, 7), (500, 600, 8))
self.turtle_change = Animation.create_texture_change(600, textures=textures)
self.turtle_change.start()
def draw(self, name: str, tex: TextureWrapper):
tex.draw_texture(name, 'petal', x=self.spawn_point + self.move_x.attribute, y=360+self.move_y.attribute, fade=0.75)
def __init__(self, tex: TextureWrapper, index: int):
super().__init__(tex, index)
self.flicker = tex.get_animation(11)
self.turtle_move = tex.get_animation(12)
self.turtle_change = tex.get_animation(13)
self.petals = {self.Petal(), self.Petal(), self.Petal(), self.Petal(), self.Petal()}
def update(self, current_time_ms: float):
self.flicker.update(current_time_ms)
if self.flicker.is_finished:
self.flicker.restart()
self.turtle_move.update(current_time_ms)
if self.turtle_move.is_finished:
self.turtle_move.restart()
self.turtle_change.update(current_time_ms)
if self.turtle_change.is_finished:
self.turtle_change.restart()
for petal in self.petals:
petal.update(current_time_ms)
if petal.move_y.is_finished:
self.petals.remove(petal)
self.petals.add(self.Petal())
def draw(self):
ray.draw_texture(self.textures[self.name][0], 0, 360, ray.WHITE)
ray.draw_texture(self.textures[self.name][2], self.screen_width//2 - 20, 380, ray.WHITE)
ray.draw_texture(self.textures[self.name][self.turtle_change.attribute], int(self.turtle_move.attribute), 550, ray.WHITE)
def draw(self, tex: TextureWrapper):
tex.draw_texture(self.name, 'background')
tex.draw_texture(self.name, 'chara')
tex.draw_texture(self.name, 'turtle', frame=self.turtle_change.attribute, x=self.turtle_move.attribute)
ray.draw_texture(self.textures[self.name][9], 0, 360, ray.WHITE)
tex.draw_texture(self.name, 'overlay')
for petal in self.petals:
petal.draw(self.textures[self.name][10])
petal.draw(self.name, tex)
class BGNormal5(BGNormalBase):
def __init__(self, index: int, screen_width: int, screen_height: int):
super().__init__(index, screen_width, screen_height)
self.flicker = Animation.create_fade(16.67*10, initial_opacity=0.75, final_opacity=0.4, reverse_delay=0)
self.flicker.start()
def __init__(self, tex: TextureWrapper, index: int):
super().__init__(tex, index)
self.flicker = tex.get_animation(14)
def update(self, current_time_ms: float):
self.flicker.update(current_time_ms)
if self.flicker.is_finished:
self.flicker.restart()
def draw(self):
ray.draw_texture(self.textures[self.name][0], 0, 360, ray.WHITE)
def draw(self, tex: TextureWrapper):
tex.draw_texture(self.name, 'background')
ray.draw_texture(self.textures[self.name][13], -35, 340, ray.WHITE)
ray.draw_texture(self.textures[self.name][12], 103, 380, ray.WHITE)
ray.draw_texture(self.textures[self.name][11], 241, 400, ray.WHITE)
ray.draw_texture(self.textures[self.name][10], 380, 380, ray.WHITE)
ray.draw_texture(self.textures[self.name][9], 518, 340, ray.WHITE)
ray.draw_texture(self.textures[self.name][4], 657, 340, ray.WHITE)
ray.draw_texture(self.textures[self.name][5], 795, 380, ray.WHITE)
ray.draw_texture(self.textures[self.name][6], 934, 400, ray.WHITE)
ray.draw_texture(self.textures[self.name][7], 1072, 380, ray.WHITE)
ray.draw_texture(self.textures[self.name][8], 1211, 340, ray.WHITE)
tex.draw_texture(self.name, 'paper_lamp', frame=9, index=0)
tex.draw_texture(self.name, 'paper_lamp', frame=8, index=1)
tex.draw_texture(self.name, 'paper_lamp', frame=7, index=2)
tex.draw_texture(self.name, 'paper_lamp', frame=6, index=3)
tex.draw_texture(self.name, 'paper_lamp', frame=5, index=4)
tex.draw_texture(self.name, 'paper_lamp', frame=4, index=5)
tex.draw_texture(self.name, 'paper_lamp', frame=3, index=6)
tex.draw_texture(self.name, 'paper_lamp', frame=2, index=7)
tex.draw_texture(self.name, 'paper_lamp', frame=1, index=8)
tex.draw_texture(self.name, 'paper_lamp', frame=0, index=9)
color = ray.fade(ray.WHITE, self.flicker.attribute)
ray.draw_texture(self.textures[self.name][14], -35 - 10, 340 - 10, color)
ray.draw_texture(self.textures[self.name][14], 103 - 10, 380 - 10, color)
ray.draw_texture(self.textures[self.name][14], 241 - 10, 400 - 10, color)
ray.draw_texture(self.textures[self.name][14], 380 - 10, 380 - 10, color)
ray.draw_texture(self.textures[self.name][14], 518 - 10, 340 - 10, color)
ray.draw_texture(self.textures[self.name][14], 657 - 10, 340 - 10, color)
ray.draw_texture(self.textures[self.name][14], 795 - 10, 380 - 10, color)
ray.draw_texture(self.textures[self.name][14], 934 - 10, 400 - 10, color)
ray.draw_texture(self.textures[self.name][14], 1072 - 10, 380 - 10, color)
ray.draw_texture(self.textures[self.name][14], 1211 - 10, 340 - 10, color)
tex.draw_texture(self.name, 'light_overlay', index=0, fade=self.flicker.attribute)
tex.draw_texture(self.name, 'light_overlay', index=1, fade=self.flicker.attribute)
tex.draw_texture(self.name, 'light_overlay', index=2, fade=self.flicker.attribute)
tex.draw_texture(self.name, 'light_overlay', index=3, fade=self.flicker.attribute)
tex.draw_texture(self.name, 'light_overlay', index=4, fade=self.flicker.attribute)
tex.draw_texture(self.name, 'light_overlay', index=5, fade=self.flicker.attribute)
tex.draw_texture(self.name, 'light_overlay', index=6, fade=self.flicker.attribute)
tex.draw_texture(self.name, 'light_overlay', index=7, fade=self.flicker.attribute)
tex.draw_texture(self.name, 'light_overlay', index=8, fade=self.flicker.attribute)
tex.draw_texture(self.name, 'light_overlay', index=9, fade=self.flicker.attribute)
ray.draw_texture(self.textures[self.name][3], (self.screen_width//2) - (self.textures[self.name][3].width//2), 360+172, ray.fade(ray.WHITE, 0.75))
tex.draw_texture(self.name, 'overlay', fade=0.75)
ray.draw_texture(self.textures[self.name][1], 50, 600, ray.fade(ray.WHITE, 0.75))
ray.draw_texture(self.textures[self.name][1], self.screen_width-50 - self.textures[self.name][2].width, 600, ray.fade(ray.WHITE, 0.75))
ray.draw_texture(self.textures[self.name][2], self.screen_width-50 - self.textures[self.name][2].width, 600, ray.WHITE)
ray.draw_texture(self.textures[self.name][2], 50, 600, ray.WHITE)
tex.draw_texture(self.name, 'lamp_overlay', index=0, fade=0.75)
tex.draw_texture(self.name, 'lamp_overlay', index=1, fade=0.75)
tex.draw_texture(self.name, 'lamp', index=0)
tex.draw_texture(self.name, 'lamp', index=1)
class BGFever:
@staticmethod
def create(screen_width: int, screen_height: int, index: int):
map = [None, None, None, None, BGFever4]
def create(tex: TextureWrapper, index: int):
map = [None, None, None, BGFever4]
selected_obj = map[index]
return selected_obj(index, screen_width, screen_height)
return selected_obj(tex, index)
class BGFeverBase:
def __init__(self, index: int, screen_width: int, screen_height: int):
self.screen_width = screen_width
self.screen_height = screen_height
self.name = 'bg_fever_a_' + str(index).zfill(2)
self.textures = (load_all_textures_from_zip(Path(f'Graphics/lumendata/enso_original/{self.name}.zip')))
def __init__(self, tex: TextureWrapper, index: int):
self.name = 'bg_fever_' + str(index)
tex.load_zip('background', f'bg_fever/{self.name}')
self.transitioned = False
def unload(self):
for texture_group in self.textures:
for texture in self.textures[texture_group]:
ray.unload_texture(texture)
class BGFever4(BGFeverBase):
def __init__(self, index: int, screen_width: int, screen_height: int):
super().__init__(index, screen_width, screen_height)
self.vertical_move = Animation.create_move(1300, start_position=0, total_distance=50, reverse_delay=0)
self.vertical_move.start()
self.horizontal_move = Animation.create_move(5000, start_position=0, total_distance=self.textures[self.name][2].width)
self.horizontal_move.start()
self.bg_texture_move_down = None
self.bg_texture_move_up = None
def __init__(self, tex: TextureWrapper, index: int):
super().__init__(tex, index)
self.vertical_move = tex.get_animation(15)
self.horizontal_move = tex.get_animation(16)
self.bg_texture_move_down = tex.get_animation(17)
self.bg_texture_move_up = tex.get_animation(18)
def start(self):
self.bg_texture_move_down = Animation.create_move(516, total_distance=400, ease_in='cubic')
self.bg_texture_move_down.start()
self.bg_texture_move_up = Animation.create_move(200, total_distance=40, delay=self.bg_texture_move_down.duration, ease_out='quadratic')
self.bg_texture_move_up.start()
def update(self, current_time_ms: float):
if self.bg_texture_move_down is not None:
self.bg_texture_move_down.update(current_time_ms)
self.bg_texture_move_down.update(current_time_ms)
if self.bg_texture_move_up is not None:
self.bg_texture_move_up.update(current_time_ms)
if self.bg_texture_move_up.is_finished and not self.transitioned:
self.transitioned = True
self.vertical_move.restart()
self.horizontal_move.restart()
self.bg_texture_move_up.update(current_time_ms)
if self.bg_texture_move_up.is_finished and not self.transitioned:
self.transitioned = True
self.vertical_move.restart()
self.horizontal_move.restart()
if self.transitioned:
self.vertical_move.update(current_time_ms)
if self.vertical_move.is_finished:
self.vertical_move.restart()
self.horizontal_move.update(current_time_ms)
if self.horizontal_move.is_finished:
self.horizontal_move.restart()
def draw(self):
if self.bg_texture_move_down is None or self.bg_texture_move_up is None:
return
texture = self.textures[self.name][0]
y = int(self.bg_texture_move_down.attribute) - int(self.bg_texture_move_up.attribute)
for i in range(0, self.screen_width + texture.width, texture.width):
ray.draw_texture(texture, i, y, ray.WHITE)
ray.draw_texture(self.textures[self.name][1], 0, (720 + 50 - int(self.vertical_move.attribute)) - y, ray.WHITE)
ray.draw_texture(self.textures[self.name][2], -int(self.horizontal_move.attribute), y, ray.WHITE)
ray.draw_texture(self.textures[self.name][2], self.textures[self.name][2].width -int(self.horizontal_move.attribute), y, ray.WHITE)
def draw(self, tex: TextureWrapper):
y = self.bg_texture_move_down.attribute - self.bg_texture_move_up.attribute
for i in range(0, 1384, 104):
tex.draw_texture(self.name, 'background', x=i, y=y)
tex.draw_texture(self.name, 'overlay_1', y=-self.vertical_move.attribute - y)
tex.draw_texture(self.name, 'overlay_2', x=-self.horizontal_move.attribute, y=y)
tex.draw_texture(self.name, 'overlay_2', x=1256 - self.horizontal_move.attribute, y=y)
class Footer:
def __init__(self, tex: TextureWrapper, index: int):

View File

@@ -31,18 +31,24 @@ def read_tjap3_score(input_file: Path):
int(score_ini['HiScore.Drums']['HiScore3']),
int(score_ini['HiScore.Drums']['HiScore4']),
int(score_ini['HiScore.Drums']['HiScore5'])]
clears = [int(score_ini['HiScore.Drums']['Clear0']),
int(score_ini['HiScore.Drums']['Clear1']),
int(score_ini['HiScore.Drums']['Clear2']),
int(score_ini['HiScore.Drums']['Clear3']),
int(score_ini['HiScore.Drums']['Clear4'])]
clears = [int(score_ini['HiScore.Drums'].get('Clear0', 0)),
int(score_ini['HiScore.Drums'].get('Clear1', 0)),
int(score_ini['HiScore.Drums'].get('Clear2', 0)),
int(score_ini['HiScore.Drums'].get('Clear3', 0)),
int(score_ini['HiScore.Drums'].get('Clear4', 0))]
if score_ini['HiScore.Drums']['PerfectRange'] != 25:
return [0],[0]
return [0],[0], None
if score_ini['HiScore.Drums']['GoodRange'] != 75:
return [0],[0]
return [0],[0], None
if score_ini['HiScore.Drums']['PoorRange'] != 108:
return [0],[0]
return scores, clears
return [0],[0], None
if score_ini['HiScore.Drums']['Perfect'] != 0:
good = score_ini['HiScore.Drums'].get('Perfect', 0)
ok = score_ini['HiScore.Drums'].get('Great', 0)
bad = score_ini['HiScore.Drums'].get('Miss', 0)
return scores, clears, [good, ok, bad]
else:
return scores, clears, None
def build_song_hashes(output_dir=Path("cache")):
if not output_dir.exists():
@@ -149,7 +155,7 @@ def build_song_hashes(output_dir=Path("cache")):
score_ini_path = tja_path.with_suffix('.tja.score.ini')
if score_ini_path.exists():
imported_scores, imported_clears = read_tjap3_score(score_ini_path)
imported_scores, imported_clears, _ = read_tjap3_score(score_ini_path)
conn = sqlite3.connect(db_path)
cursor = conn.cursor()
for i in range(len(imported_scores)):

View File

@@ -24,11 +24,11 @@ class Texture:
self.height = self.texture.height
self.is_frames = isinstance(self.texture, list)
self.x = 0
self.y = 0
self.x2 = self.width
self.y2 = self.height
self.controllable = False
self.x: list[int] = [0]
self.y: list[int] = [0]
self.x2: list[int] = [self.width]
self.y2: list[int] = [self.height]
self.controllable: list[bool] = [False]
class TextureWrapper:
def __init__(self):
@@ -50,20 +50,35 @@ class TextureWrapper:
if index not in self.animations:
raise Exception(f"Unable to find id {index} in loaded animations")
if is_copy:
return copy.deepcopy(self.animations[index])
new_anim = copy.deepcopy(self.animations[index])
if self.animations[index].loop:
new_anim.start()
return new_anim
if self.animations[index].loop:
self.animations[index].start()
return self.animations[index]
def update_attr(self, subset: str, texture: str, attr: str, value: float | int):
tex_object = self.textures[subset][texture]
if hasattr(tex_object, attr):
setattr(tex_object, attr, tex_object.init_vals[attr] + value)
def _read_tex_obj_data(self, tex_mapping: dict, tex_object: Texture):
tex_object.x = tex_mapping.get("x", 0)
tex_object.y = tex_mapping.get("y", 0)
tex_object.x2 = tex_mapping.get("x2", tex_object.width)
tex_object.y2 = tex_mapping.get("y2", tex_object.height)
tex_object.controllable = tex_mapping.get("controllable", False)
def _read_tex_obj_data(self, tex_mapping: dict | list, tex_object: Texture):
if isinstance(tex_mapping, list):
for i in range(len(tex_mapping)):
if i == 0:
tex_object.x[i] = tex_mapping[i].get("x", 0)
tex_object.y[i] = tex_mapping[i].get("y", 0)
tex_object.x2[i] = tex_mapping[i].get("x2", tex_object.width)
tex_object.y2[i] = tex_mapping[i].get("y2", tex_object.height)
tex_object.controllable[i] = tex_mapping[i].get("controllable", False)
else:
tex_object.x.append(tex_mapping[i].get("x", 0))
tex_object.y.append(tex_mapping[i].get("y", 0))
tex_object.x2.append(tex_mapping[i].get("x2", tex_object.width))
tex_object.y2.append(tex_mapping[i].get("y2", tex_object.height))
tex_object.controllable.append(tex_mapping[i].get("controllable", False))
else:
tex_object.x = [tex_mapping.get("x", 0)]
tex_object.y = [tex_mapping.get("y", 0)]
tex_object.x2 = [tex_mapping.get("x2", tex_object.width)]
tex_object.y2 = [tex_mapping.get("y2", tex_object.height)]
tex_object.controllable = [tex_mapping.get("controllable", False)]
def load_animations(self, screen_name: str):
screen_path = self.graphics_path / screen_name
@@ -125,26 +140,27 @@ class TextureWrapper:
continue
self.load_zip(screen_name, zip.name)
def control(self, tex_object: Texture):
def control(self, tex_object: Texture, index: int = 0):
distance = 1
if ray.is_key_down(ray.KeyboardKey.KEY_LEFT_SHIFT):
distance = 10
if ray.is_key_pressed(ray.KeyboardKey.KEY_LEFT):
tex_object.x -= distance
print(f"{tex_object.name}: {tex_object.x}, {tex_object.y}")
tex_object.x[index] -= distance
print(f"{tex_object.name}: {tex_object.x[index]}, {tex_object.y[index]}")
if ray.is_key_pressed(ray.KeyboardKey.KEY_RIGHT):
tex_object.x += distance
print(f"{tex_object.name}: {tex_object.x}, {tex_object.y}")
tex_object.x[index] += distance
print(f"{tex_object.name}: {tex_object.x[index]}, {tex_object.y[index]}")
if ray.is_key_pressed(ray.KeyboardKey.KEY_UP):
tex_object.y -= distance
print(f"{tex_object.name}: {tex_object.x}, {tex_object.y}")
tex_object.y[index] -= distance
print(f"{tex_object.name}: {tex_object.x[index]}, {tex_object.y[index]}")
if ray.is_key_pressed(ray.KeyboardKey.KEY_DOWN):
tex_object.y += distance
print(f"{tex_object.name}: {tex_object.x}, {tex_object.y}")
tex_object.y[index] += distance
print(f"{tex_object.name}: {tex_object.x[index]}, {tex_object.y[index]}")
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, fade: float = 1.1) -> None:
origin: ray.Vector2 = ray.Vector2(0,0), rotation: float = 0, fade: float = 1.1,
index: int = 0) -> None:
mirror_x = -1 if mirror == 'horizontal' else 1
mirror_y = -1 if mirror == 'vertical' else 1
if fade != 1.1:
@@ -154,9 +170,9 @@ class TextureWrapper:
tex_object = self.textures[subset][texture]
source_rect = ray.Rectangle(0, 0, tex_object.width * mirror_x, tex_object.height * mirror_y)
if center:
dest_rect = ray.Rectangle(tex_object.x + (tex_object.width//2) - ((tex_object.width * scale)//2) + x, tex_object.y + (tex_object.height//2) - ((tex_object.height * scale)//2) + y, tex_object.x2*scale + x2, tex_object.y2*scale + y2)
dest_rect = ray.Rectangle(tex_object.x[index] + (tex_object.width//2) - ((tex_object.width * scale)//2) + x, tex_object.y[index] + (tex_object.height//2) - ((tex_object.height * scale)//2) + y, tex_object.x2[index]*scale + x2, tex_object.y2[index]*scale + y2)
else:
dest_rect = ray.Rectangle(tex_object.x + x, tex_object.y + y, tex_object.x2*scale + x2, tex_object.y2*scale + y2)
dest_rect = ray.Rectangle(tex_object.x[index] + x, tex_object.y[index] + y, tex_object.x2[index]*scale + x2, tex_object.y2[index]*scale + y2)
if tex_object.is_frames:
if not isinstance(tex_object.texture, list):
raise Exception("Texture was marked as multiframe but is only 1 texture")
@@ -167,7 +183,7 @@ class TextureWrapper:
if isinstance(tex_object.texture, list):
raise Exception("Texture is multiframe but was called as 1 texture")
ray.draw_texture_pro(tex_object.texture, source_rect, dest_rect, origin, rotation, final_color)
if tex_object.controllable:
if tex_object.controllable[index]:
self.control(tex_object)
tex = TextureWrapper()

View File

@@ -1,14 +1,10 @@
import pyray as ray
from libs.texture import tex
from libs.utils import get_current_ms
from scenes.song_select import ScoreHistory
class DevScreen:
def __init__(self, width: int, height: int):
self.width = width
self.height = height
def __init__(self):
self.width = 1280
self.height = 720
self.screen_init = False
def on_screen_start(self):

View File

@@ -20,9 +20,7 @@ class State:
SELECT_MODE = 1
class EntryScreen:
def __init__(self, width: int, height: int):
self.width = width
self.height = height
def __init__(self):
self.screen_init = False
def load_textures(self):
@@ -51,9 +49,7 @@ class EntryScreen:
self.cloud_resize_loop = tex.get_animation(6)
self.cloud_texture_change = tex.get_animation(7)
self.cloud_fade = tex.get_animation(8)
self.cloud_resize_loop.start()
self.side_select_fade.start()
self.bg_flicker.start()
audio.play_sound(self.bgm)
def on_screen_end(self, next_screen: str):
@@ -101,8 +97,6 @@ class EntryScreen:
self.on_screen_start()
self.side_select_fade.update(get_current_ms())
self.bg_flicker.update(get_current_ms())
if self.bg_flicker.is_finished:
self.bg_flicker.restart()
self.drum_move_1.update(get_current_ms())
self.drum_move_2.update(get_current_ms())
self.drum_move_3.update(get_current_ms())
@@ -110,8 +104,6 @@ class EntryScreen:
self.cloud_texture_change.update(get_current_ms())
self.cloud_fade.update(get_current_ms())
self.cloud_resize_loop.update(get_current_ms())
if self.cloud_resize_loop.is_finished:
self.cloud_resize_loop.restart()
self.box_manager.update(get_current_ms())
if self.box_manager.is_finished():
return self.on_screen_end(self.box_manager.selected_box())
@@ -152,37 +144,30 @@ class EntryScreen:
tex.draw_texture('side_select', '2P', fade=fade)
if self.side == 0:
tex.draw_texture('side_select', '1P_highlight', fade=fade)
tex.textures['side_select']['1P2P_outline'].x = 261
tex.draw_texture('side_select', '1P2P_outline', fade=fade, mirror='horizontal')
tex.draw_texture('side_select', '1P2P_outline', index=0, fade=fade, mirror='horizontal')
elif self.side == 1:
tex.draw_texture('side_select', 'cancel_highlight', fade=fade)
tex.draw_texture('side_select', 'cancel_outline', fade=fade)
else:
tex.draw_texture('side_select', '2P_highlight', fade=fade)
tex.textures['side_select']['1P2P_outline'].x = 762
tex.draw_texture('side_select', '1P2P_outline', fade=fade)
tex.draw_texture('side_select', '1P2P_outline', index=1, fade=fade)
tex.draw_texture('side_select', 'cancel_text', fade=fade)
def draw_player_drum(self):
move_x = self.drum_move_3.attribute
move_y = self.drum_move_1.attribute + self.drum_move_2.attribute
tex.update_attr('side_select', 'red_drum', 'x', move_x)
tex.update_attr('side_select', 'red_drum', 'y', move_y)
tex.update_attr('side_select', 'blue_drum', 'y', move_y)
if self.side == 0:
tex.draw_texture('side_select', 'red_drum')
offset = 0
tex.draw_texture('side_select', 'red_drum', x=move_x, y=move_y)
else:
move_x *= -1
tex.textures['side_select']['cloud'].init_vals['x'] = tex.textures['side_select']['blue_drum'].init_vals['x']
tex.update_attr('side_select', 'blue_drum', 'x', move_x)
tex.draw_texture('side_select', 'blue_drum')
offset = 620
tex.draw_texture('side_select', 'blue_drum', x=move_x, y=move_y)
scale = self.cloud_resize.attribute
if self.cloud_resize.is_finished:
scale = max(1, self.cloud_resize_loop.attribute)
tex.update_attr('side_select', 'cloud', 'x', move_x)
tex.update_attr('side_select', 'cloud', 'y', move_y)
tex.draw_texture('side_select', 'cloud', frame=self.cloud_texture_change.attribute, fade=self.cloud_fade.attribute, scale=scale, center=True)
tex.draw_texture('side_select', 'cloud', x=move_x + offset, y=move_y, frame=self.cloud_texture_change.attribute, fade=self.cloud_fade.attribute, scale=scale, center=True)
def draw_mode_select(self):
self.draw_player_drum()
@@ -201,7 +186,7 @@ class EntryScreen:
tex.draw_texture('global', 'player_entry')
if self.box_manager.is_finished():
ray.draw_rectangle(0, 0, self.width, self.height, ray.BLACK)
ray.draw_rectangle(0, 0, 1280, 720, ray.BLACK)
def draw_3d(self):
pass
@@ -214,8 +199,8 @@ class Box:
if isinstance(self.box_tex_obj.texture, list):
raise Exception("Box texture cannot be iterable")
self.texture = self.box_tex_obj.texture
self.x = self.box_tex_obj.x
self.y = self.box_tex_obj.y
self.x = self.box_tex_obj.x[0]
self.y = self.box_tex_obj.y[0]
self.move = tex.get_animation(10)
self.open = tex.get_animation(11)
self.is_selected = False

View File

@@ -35,9 +35,8 @@ from libs.video import VideoPlayer
class GameScreen:
JUDGE_X = 414
def __init__(self, width: int, height: int):
self.width = width
self.height = height
def __init__(self):
self.width = 1280
self.current_ms = 0
self.screen_init = False
self.end_ms = 0
@@ -86,7 +85,7 @@ class GameScreen:
self.movie = None
self.song_music = None
tex.load_screen_textures('game')
self.background = Background(self.width, self.height, global_data.player_num)
self.background = Background(global_data.player_num)
self.load_sounds()
self.init_tja(global_data.selected_song, session_data.selected_difficulty)
self.song_info = SongInfo(session_data.song_title, 'TEST')
@@ -1056,7 +1055,6 @@ class KusudamaAnimation:
self.renda_move_up.start()
self.renda_move_down.start()
self.renda_fade_in.start()
self.renda_breathe.start()
self.open.reset()
self.renda_fade_out.reset()
@@ -1085,8 +1083,6 @@ class KusudamaAnimation:
self.breathing.update(current_ms)
self.renda_breathe.update(current_ms)
self.open.update(current_ms)
if self.renda_breathe.is_finished:
self.renda_breathe.restart()
self.is_finished = self.fade_out.is_finished
def draw(self):
y = self.move_down.attribute - self.move_up.attribute
@@ -1255,12 +1251,9 @@ class SongInfo:
self.genre = genre
self.song_title = OutlinedText(song_name, 40, ray.WHITE, ray.BLACK, outline_thickness=5)
self.fade = tex.get_animation(3)
self.fade.start()
def update(self, current_ms: float):
self.fade.update(current_ms)
if self.fade.is_finished:
self.fade.restart()
def draw(self):
tex.draw_texture('song_info', 'song_num', fade=self.fade.attribute, frame=global_data.songs_played % 4)

View File

@@ -10,9 +10,9 @@ from scenes.song_select import SongSelectScreen
class LoadScreen:
def __init__(self, width: int, height: int, song_select_screen: SongSelectScreen):
self.width = width
self.height = height
def __init__(self, song_select_screen: SongSelectScreen):
self.width = 1280
self.height = 720
self.screen_init = False
self.songs_loaded = False
self.navigator_started = False
@@ -20,10 +20,10 @@ class LoadScreen:
self.song_select_screen = song_select_screen
# Progress bar settings
self.progress_bar_width = width * 0.43
self.progress_bar_width = self.width * 0.43
self.progress_bar_height = 50
self.progress_bar_x = (width - self.progress_bar_width) // 2
self.progress_bar_y = height * 0.85
self.progress_bar_x = (self.width - self.progress_bar_width) // 2
self.progress_bar_y = self.height * 0.85
# Thread references
self.loading_thread = None

View File

@@ -22,9 +22,9 @@ class State:
RAINBOW = 2
class ResultScreen:
def __init__(self, width: int, height: int):
self.width = width
self.height = height
def __init__(self):
self.width = 1280
self.height = 720
self.screen_init = False
self.alpha_shader = ray.load_shader('', 'shader/grayscale_alpha.fs')

View File

@@ -13,9 +13,7 @@ from libs.utils import (
class SettingsScreen:
def __init__(self, width: int, height: int):
self.width = width
self.height = height
def __init__(self):
self.screen_init = False
self.config = global_data.config
self.headers = list(self.config.keys())

View File

@@ -32,11 +32,10 @@ class State:
class SongSelectScreen:
BOX_CENTER = 444
def __init__(self, screen_width: int, screen_height: int):
def __init__(self, screen_width: int = 1280):
self.screen_init = False
self.root_dir = global_data.config["paths"]["tja_path"]
self.screen_width = screen_width
self.screen_height = screen_height
def load_navigator(self):
self.navigator = FileNavigator(self.root_dir)
@@ -65,7 +64,6 @@ class SongSelectScreen:
self.diff_selector_move_1 = tex.get_animation(26)
self.diff_selector_move_2 = tex.get_animation(27)
self.diff_select_move_right = False
self.background_move.start()
self.state = State.BROWSING
self.selected_difficulty = -3
self.prev_diff = -3
@@ -361,9 +359,6 @@ class SongSelectScreen:
if self.text_fade_out.is_finished:
self.selected_song = True
if self.background_move.is_finished:
self.background_move.restart()
if self.last_texture_index != self.texture_index:
if not self.background_fade_change.is_started:
self.background_fade_change.start()
@@ -775,7 +770,7 @@ class YellowBox:
self.center_width = self.center_out.attribute
self.top_y = self.top_y_out.attribute
self.center_height = self.center_h_out.attribute
self.bottom_y = tex.textures['yellow_box']['yellow_box_bottom_right'].y
self.bottom_y = tex.textures['yellow_box']['yellow_box_bottom_right'].y[0]
self.edge_height = tex.textures['yellow_box']['yellow_box_bottom_right'].height
def reset(self):
@@ -1004,7 +999,6 @@ class DiffSortSelect:
self.bounce_down_2 = tex.get_animation(25)
self.bg_resize.start()
self.diff_fade_in.start()
self.box_flicker.start()
def update(self, current_ms):
self.bg_resize.update(current_ms)
@@ -1014,8 +1008,6 @@ class DiffSortSelect:
self.bounce_down_1.update(current_ms)
self.bounce_up_2.update(current_ms)
self.bounce_down_2.update(current_ms)
if self.box_flicker.is_finished:
self.box_flicker.restart()
def get_random_sort(self):
diff = random.randint(0, 4)
@@ -1113,7 +1105,7 @@ class DiffSortSelect:
if self.confirmation:
texture = tex.textures['diff_sort']['level_box']
ray.draw_rectangle(texture.x, texture.y, texture.x2, texture.y2, ray.fade(ray.BLACK, 0.5))
ray.draw_rectangle(texture.x[0], texture.y[0], texture.x2[0], texture.y2[0], ray.fade(ray.BLACK, 0.5))
y = -self.bounce_up_1.attribute + self.bounce_down_1.attribute - self.bounce_up_2.attribute + self.bounce_down_2.attribute
for i in range(3):
if i == self.confirm_index:
@@ -1146,8 +1138,6 @@ class NeiroSelector:
self.move.start()
self.blue_arrow_fade = tex.get_animation(29)
self.blue_arrow_move = tex.get_animation(30)
self.blue_arrow_move.start()
self.blue_arrow_fade.start()
self.text = OutlinedText(self.sounds[self.selected_sound], 50, ray.WHITE, ray.BLACK)
self.text_2 = OutlinedText(self.sounds[self.selected_sound], 50, ray.WHITE, ray.BLACK)
self.move_sideways = tex.get_animation(31)
@@ -1205,10 +1195,6 @@ class NeiroSelector:
if self.move_sideways.is_finished:
self.text.unload()
self.text = OutlinedText(self.sounds[self.selected_sound], 50, ray.WHITE, ray.BLACK)
if self.blue_arrow_fade.is_finished:
self.blue_arrow_fade.restart()
if self.blue_arrow_move.is_finished:
self.blue_arrow_move.restart()
self.is_finished = self.move.is_finished and self.is_confirmed
def draw(self):
@@ -1262,8 +1248,6 @@ class ModifierSelector:
self.is_finished = False
self.blue_arrow_fade = tex.get_animation(29)
self.blue_arrow_move = tex.get_animation(30)
self.blue_arrow_move.start()
self.blue_arrow_fade.start()
self.move = tex.get_animation(28)
self.move.start()
self.move_sideways = tex.get_animation(31)
@@ -1301,11 +1285,6 @@ class ModifierSelector:
self.text_speed.unload()
self.text_speed = OutlinedText(str(current_value), 30, ray.WHITE, ray.BLACK, outline_thickness=3.5)
if self.blue_arrow_fade.is_finished:
self.blue_arrow_fade.restart()
if self.blue_arrow_move.is_finished:
self.blue_arrow_move.restart()
def confirm(self):
if self.is_confirmed:
return

View File

@@ -18,9 +18,7 @@ class State:
ATTRACT_VIDEO = 2
class TitleScreen:
def __init__(self, width: int, height: int):
self.width = width
self.height = height
def __init__(self):
video_dir = Path(global_data.config["paths"]["video_path"]) / "op_videos"
self.op_video_list = [file for file in video_dir.glob("**/*.mp4")]
video_dir = Path(global_data.config["paths"]["video_path"]) / "attract_videos"
@@ -180,14 +178,14 @@ class WarningScreen:
else:
self.shadow_fade.restart()
self.is_finished = self.chara_1_frame.is_finished
def draw(self, fade: float, fade_2: float):
tex.draw_texture('warning', 'chara_0_shadow', fade=fade_2)
tex.draw_texture('warning', 'chara_0', frame=self.chara_0_frame.attribute, fade=fade)
def draw(self, fade: float, fade_2: float, y_pos: float):
tex.draw_texture('warning', 'chara_0_shadow', fade=fade_2, y=y_pos)
tex.draw_texture('warning', 'chara_0', frame=self.chara_0_frame.attribute, fade=fade, y=y_pos)
tex.draw_texture('warning', 'chara_1_shadow', fade=fade_2)
tex.draw_texture('warning', 'chara_1_shadow', fade=fade_2, y=y_pos)
if -1 < self.chara_1_frame.attribute-1 < 7:
tex.draw_texture('warning', 'chara_1', frame=self.chara_1_frame.attribute-1, fade=self.shadow_fade.attribute)
tex.draw_texture('warning', 'chara_1', frame=self.chara_1_frame.attribute, fade=fade)
tex.draw_texture('warning', 'chara_1', frame=self.chara_1_frame.attribute-1, fade=self.shadow_fade.attribute, y=y_pos)
tex.draw_texture('warning', 'chara_1', frame=self.chara_1_frame.attribute, fade=fade, y=y_pos)
class Board:
def __init__(self):
@@ -209,10 +207,9 @@ class WarningScreen:
self.y_pos = self.move_up.attribute
else:
self.y_pos = self.move_down.attribute
tex.update_attr('warning', 'warning_box', 'y', self.y_pos)
def draw(self):
tex.draw_texture('warning', 'warning_box')
tex.draw_texture('warning', 'warning_box', y=self.y_pos)
def __init__(self, current_ms: float):
@@ -238,10 +235,6 @@ class WarningScreen:
elapsed_time = current_ms - self.start_ms
self.warning_x.update(current_ms, title_screen.sound_warning_error)
self.characters.update(current_ms)
tex.update_attr('warning', 'chara_0', 'y', self.board.y_pos)
tex.update_attr('warning', 'chara_0_shadow', 'y', self.board.y_pos)
tex.update_attr('warning', 'chara_1_shadow', 'y', self.board.y_pos)
tex.update_attr('warning', 'chara_1', 'y', self.board.y_pos)
if self.characters.is_finished:
self.warning_bachi_hit.update(current_ms, title_screen.sound_bachi_hit)
@@ -256,7 +249,7 @@ class WarningScreen:
def draw(self):
self.board.draw()
self.warning_x.draw_bg()
self.characters.draw(self.fade_in.attribute, min(self.fade_in.attribute, 0.75))
self.characters.draw(self.fade_in.attribute, min(self.fade_in.attribute, 0.75), self.board.y_pos)
self.warning_x.draw_fg()
self.warning_bachi_hit.draw()