3 Commits

Author SHA1 Message Date
Anthony Samms
c5a3f1e9e5 disable discord 2026-02-02 09:57:19 -05:00
Anthony Samms
46ddce2443 add funassyi 2026-01-23 10:39:35 -05:00
Anthony Samms
ae2702b3dd add funassyi 2026-01-23 10:38:48 -05:00
7 changed files with 136 additions and 131 deletions

View File

@@ -47,6 +47,7 @@ from scenes.two_player.result import TwoPlayerResultScreen
from scenes.two_player.song_select import TwoPlayerSongSelectScreen from scenes.two_player.song_select import TwoPlayerSongSelectScreen
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
'''
DISCORD_APP_ID = '1451423960401973353' DISCORD_APP_ID = '1451423960401973353'
try: try:
RPC = Presence(DISCORD_APP_ID) RPC = Presence(DISCORD_APP_ID)
@@ -55,6 +56,7 @@ try:
except Exception as e: except Exception as e:
discord_connected = False discord_connected = False
logger.warning(f"Could not connect to Discord: {e}") logger.warning(f"Could not connect to Discord: {e}")
'''
class Screens: class Screens:
TITLE = "TITLE" TITLE = "TITLE"
@@ -279,13 +281,14 @@ def check_discord_heartbeat(current_screen):
details = f"Playing Song: {global_data.session_data[global_data.player_num].song_title}" details = f"Playing Song: {global_data.session_data[global_data.player_num].song_title}"
else: else:
details = "Idling" details = "Idling"
'''
RPC.update( RPC.update(
state=f"In Screen {current_screen}", state=f"In Screen {current_screen}",
details=details, details=details,
large_text="PyTaiko", large_text="PyTaiko",
start=get_current_ms()/1000, start=get_current_ms()/1000,
buttons=[{"label": "Play Now", "url": "https://github.com/Yonokid/PyTaiko"}] buttons=[{"label": "Play Now", "url": "https://github.com/Yonokid/PyTaiko"}]
) )'''
def draw_fps(last_fps: int): def draw_fps(last_fps: int):
curr_fps = ray.GetFPS() curr_fps = ray.GetFPS()
@@ -400,9 +403,9 @@ def main():
while not ray.WindowShouldClose(): while not ray.WindowShouldClose():
current_time = get_current_ms() current_time = get_current_ms()
if discord_connected and current_time > last_discord_check + 1000: #if discord_connected and current_time > last_discord_check + 1000:
check_discord_heartbeat(current_screen) #check_discord_heartbeat(current_screen)
last_discord_check = current_time #last_discord_check = current_time
if ray.IsKeyPressed(global_data.config["keys"]["fullscreen_key"]): if ray.IsKeyPressed(global_data.config["keys"]["fullscreen_key"]):
ray.ToggleFullscreen() ray.ToggleFullscreen()
@@ -444,8 +447,8 @@ def main():
ray.CloseWindow() ray.CloseWindow()
audio.close_audio_device() audio.close_audio_device()
if discord_connected: #if discord_connected:
RPC.close() #RPC.close()
global_tex.unload_textures() global_tex.unload_textures()
screen_mapping[current_screen].on_screen_end("LOADING") screen_mapping[current_screen].on_screen_end("LOADING")
logger.info("Window closed and audio device shut down") logger.info("Window closed and audio device shut down")

View File

@@ -1,6 +1,5 @@
import logging import logging
import platform import platform
import pyray as ray
from pathlib import Path from pathlib import Path
import cffi import cffi
@@ -133,7 +132,6 @@ class AudioEngine:
self.music_streams = {} self.music_streams = {}
self.audio_device_ready = False self.audio_device_ready = False
self.volume_presets = volume_presets self.volume_presets = volume_presets
self.lib = lib
if sounds_path is None: if sounds_path is None:
self.sounds_path = Path(f"Skins/{get_config()['paths']['skin']}/Sounds") self.sounds_path = Path(f"Skins/{get_config()['paths']['skin']}/Sounds")
@@ -141,15 +139,15 @@ class AudioEngine:
self.sounds_path = sounds_path self.sounds_path = sounds_path
def set_log_level(self, level: int): def set_log_level(self, level: int):
self.lib.set_log_level(level) # type: ignore lib.set_log_level(level) # type: ignore
def list_host_apis(self): def list_host_apis(self):
"""Prints a list of available host APIs to the console""" """Prints a list of available host APIs to the console"""
self.lib.list_host_apis() # type: ignore lib.list_host_apis() # type: ignore
def get_host_api_name(self, api_id: int) -> str: def get_host_api_name(self, api_id: int) -> str:
"""Returns the name of the host API with the given ID""" """Returns the name of the host API with the given ID"""
result = self.lib.get_host_api_name(api_id) # type: ignore result = lib.get_host_api_name(api_id) # type: ignore
if result == ffi.NULL: if result == ffi.NULL:
return "" return ""
result = ffi.string(result) result = ffi.string(result)
@@ -160,12 +158,12 @@ class AudioEngine:
def init_audio_device(self) -> bool: def init_audio_device(self) -> bool:
"""Initialize the audio device""" """Initialize the audio device"""
try: try:
self.lib.init_audio_device(self.device_type, self.target_sample_rate, self.buffer_size) # type: ignore lib.init_audio_device(self.device_type, self.target_sample_rate, self.buffer_size) # type: ignore
self.audio_device_ready = self.lib.is_audio_device_ready() # type: ignore self.audio_device_ready = lib.is_audio_device_ready() # type: ignore
file_path_str = str(self.sounds_path / 'don.wav').encode('utf-8') file_path_str = str(self.sounds_path / 'don.wav').encode('utf-8')
self.don = self.lib.load_sound(file_path_str) # type: ignore self.don = lib.load_sound(file_path_str) # type: ignore
file_path_str = str(self.sounds_path / 'ka.wav').encode('utf-8') file_path_str = str(self.sounds_path / 'ka.wav').encode('utf-8')
self.kat = self.lib.load_sound(file_path_str) # type: ignore self.kat = lib.load_sound(file_path_str) # type: ignore
if self.audio_device_ready: if self.audio_device_ready:
logger.info("Audio device initialized successfully") logger.info("Audio device initialized successfully")
return self.audio_device_ready return self.audio_device_ready
@@ -182,9 +180,9 @@ class AudioEngine:
for music_id in list(self.music_streams.keys()): for music_id in list(self.music_streams.keys()):
self.unload_music_stream(music_id) self.unload_music_stream(music_id)
self.lib.unload_sound(self.don) # type: ignore lib.unload_sound(self.don) # type: ignore
self.lib.unload_sound(self.kat) # type: ignore lib.unload_sound(self.kat) # type: ignore
self.lib.close_audio_device() # type: ignore lib.close_audio_device() # type: ignore
self.audio_device_ready = False self.audio_device_ready = False
logger.info("Audio device closed") logger.info("Audio device closed")
except Exception as e: except Exception as e:
@@ -192,15 +190,15 @@ class AudioEngine:
def is_audio_device_ready(self) -> bool: def is_audio_device_ready(self) -> bool:
"""Check if audio device is ready""" """Check if audio device is ready"""
return self.lib.is_audio_device_ready() # type: ignore return lib.is_audio_device_ready() # type: ignore
def set_master_volume(self, volume: float) -> None: def set_master_volume(self, volume: float) -> None:
"""Set master volume (0.0 to 1.0)""" """Set master volume (0.0 to 1.0)"""
self.lib.set_master_volume(max(0.0, min(1.0, volume))) # type: ignore lib.set_master_volume(max(0.0, min(1.0, volume))) # type: ignore
def get_master_volume(self) -> float: def get_master_volume(self) -> float:
"""Get master volume""" """Get master volume"""
return self.lib.get_master_volume() # type: ignore return lib.get_master_volume() # type: ignore
# Sound management # Sound management
def load_sound(self, file_path: Path, name: str) -> str: def load_sound(self, file_path: Path, name: str) -> str:
@@ -211,13 +209,13 @@ class AudioEngine:
file_path_str = str(file_path).encode('cp932', errors='replace') file_path_str = str(file_path).encode('cp932', errors='replace')
else: else:
file_path_str = str(file_path).encode('utf-8') file_path_str = str(file_path).encode('utf-8')
sound = self.lib.load_sound(file_path_str) # type: ignore sound = lib.load_sound(file_path_str) # type: ignore
if not self.lib.is_sound_valid(sound): # type: ignore if not lib.is_sound_valid(sound): # type: ignore
file_path_str = str(file_path).encode('utf-8') file_path_str = str(file_path).encode('utf-8')
sound = self.lib.load_sound(file_path_str) # type: ignore sound = lib.load_sound(file_path_str) # type: ignore
if self.lib.is_sound_valid(sound): # type: ignore if lib.is_sound_valid(sound): # type: ignore
self.sounds[name] = sound self.sounds[name] = sound
return name return name
else: else:
@@ -230,7 +228,7 @@ class AudioEngine:
def unload_sound(self, name: str) -> None: def unload_sound(self, name: str) -> None:
"""Unload a sound by name""" """Unload a sound by name"""
if name in self.sounds: if name in self.sounds:
self.lib.unload_sound(self.sounds[name]) # type: ignore lib.unload_sound(self.sounds[name]) # type: ignore
del self.sounds[name] del self.sounds[name]
else: else:
logger.warning(f"Sound {name} not found") logger.warning(f"Sound {name} not found")
@@ -265,41 +263,41 @@ class AudioEngine:
"""Play a sound""" """Play a sound"""
if name == 'don': if name == 'don':
if volume_preset: if volume_preset:
self.lib.set_sound_volume(self.don, self.volume_presets[volume_preset]) # type: ignore lib.set_sound_volume(self.don, self.volume_presets[volume_preset]) # type: ignore
self.lib.play_sound(self.don) # type: ignore lib.play_sound(self.don) # type: ignore
elif name == 'kat': elif name == 'kat':
if volume_preset: if volume_preset:
self.lib.set_sound_volume(self.kat, self.volume_presets[volume_preset]) # type: ignore lib.set_sound_volume(self.kat, self.volume_presets[volume_preset]) # type: ignore
self.lib.play_sound(self.kat) # type: ignore lib.play_sound(self.kat) # type: ignore
elif name in self.sounds: elif name in self.sounds:
sound = self.sounds[name] sound = self.sounds[name]
if volume_preset: if volume_preset:
self.lib.set_sound_volume(sound, self.volume_presets[volume_preset]) # type: ignore lib.set_sound_volume(sound, self.volume_presets[volume_preset]) # type: ignore
self.lib.play_sound(sound) # type: ignore lib.play_sound(sound) # type: ignore
else: else:
logger.warning(f"Sound {name} not found") logger.warning(f"Sound {name} not found")
def stop_sound(self, name: str) -> None: def stop_sound(self, name: str) -> None:
"""Stop a sound""" """Stop a sound"""
if name == 'don': if name == 'don':
self.lib.stop_sound(self.don) # type: ignore lib.stop_sound(self.don) # type: ignore
elif name == 'kat': elif name == 'kat':
self.lib.stop_sound(self.kat) # type: ignore lib.stop_sound(self.kat) # type: ignore
if name in self.sounds: if name in self.sounds:
sound = self.sounds[name] sound = self.sounds[name]
self.lib.stop_sound(sound) # type: ignore lib.stop_sound(sound) # type: ignore
else: else:
logger.warning(f"Sound {name} not found") logger.warning(f"Sound {name} not found")
def is_sound_playing(self, name: str) -> bool: def is_sound_playing(self, name: str) -> bool:
"""Check if a sound is playing""" """Check if a sound is playing"""
if name == 'don': if name == 'don':
return self.lib.is_sound_playing(self.don) # type: ignore return lib.is_sound_playing(self.don) # type: ignore
elif name == 'kat': elif name == 'kat':
return self.lib.is_sound_playing(self.kat) # type: ignore return lib.is_sound_playing(self.kat) # type: ignore
if name in self.sounds: if name in self.sounds:
sound = self.sounds[name] sound = self.sounds[name]
return self.lib.is_sound_playing(sound) # type: ignore return lib.is_sound_playing(sound) # type: ignore
else: else:
logger.warning(f"Sound {name} not found") logger.warning(f"Sound {name} not found")
return False return False
@@ -307,24 +305,24 @@ class AudioEngine:
def set_sound_volume(self, name: str, volume: float) -> None: def set_sound_volume(self, name: str, volume: float) -> None:
"""Set the volume of a specific sound""" """Set the volume of a specific sound"""
if name == 'don': if name == 'don':
self.lib.set_sound_volume(self.don, volume) # type: ignore lib.set_sound_volume(self.don, volume) # type: ignore
elif name == 'kat': elif name == 'kat':
self.lib.set_sound_volume(self.kat, volume) # type: ignore lib.set_sound_volume(self.kat, volume) # type: ignore
elif name in self.sounds: elif name in self.sounds:
sound = self.sounds[name] sound = self.sounds[name]
self.lib.set_sound_volume(sound, volume) # type: ignore lib.set_sound_volume(sound, volume) # type: ignore
else: else:
logger.warning(f"Sound {name} not found") logger.warning(f"Sound {name} not found")
def set_sound_pan(self, name: str, pan: float) -> None: def set_sound_pan(self, name: str, pan: float) -> None:
"""Set the pan of a specific sound""" """Set the pan of a specific sound"""
if name == 'don': if name == 'don':
self.lib.set_sound_pan(self.don, pan) # type: ignore lib.set_sound_pan(self.don, pan) # type: ignore
elif name == 'kat': elif name == 'kat':
self.lib.set_sound_pan(self.kat, pan) # type: ignore lib.set_sound_pan(self.kat, pan) # type: ignore
elif name in self.sounds: elif name in self.sounds:
sound = self.sounds[name] sound = self.sounds[name]
self.lib.set_sound_pan(sound, pan) # type: ignore lib.set_sound_pan(sound, pan) # type: ignore
else: else:
logger.warning(f"Sound {name} not found") logger.warning(f"Sound {name} not found")
@@ -337,13 +335,13 @@ class AudioEngine:
else: else:
file_path_str = str(file_path).encode('utf-8') file_path_str = str(file_path).encode('utf-8')
music = self.lib.load_music_stream(file_path_str) # type: ignore music = lib.load_music_stream(file_path_str) # type: ignore
if not self.lib.is_music_valid(music): # type: ignore if not lib.is_music_valid(music): # type: ignore
file_path_str = str(file_path).encode('utf-8') file_path_str = str(file_path).encode('utf-8')
music = self.lib.load_music_stream(file_path_str) # type: ignore music = lib.load_music_stream(file_path_str) # type: ignore
if self.lib.is_music_valid(music): # type: ignore if lib.is_music_valid(music): # type: ignore
self.music_streams[name] = music self.music_streams[name] = music
logger.info(f"Loaded music stream from {file_path} as {name}") logger.info(f"Loaded music stream from {file_path} as {name}")
return name return name
@@ -355,10 +353,10 @@ class AudioEngine:
"""Play a music stream""" """Play a music stream"""
if name in self.music_streams: if name in self.music_streams:
music = self.music_streams[name] music = self.music_streams[name]
self.lib.seek_music_stream(music, 0) # type: ignore lib.seek_music_stream(music, 0) # type: ignore
if volume_preset: if volume_preset:
self.lib.set_music_volume(music, self.volume_presets[volume_preset]) # type: ignore lib.set_music_volume(music, self.volume_presets[volume_preset]) # type: ignore
self.lib.play_music_stream(music) # type: ignore lib.play_music_stream(music) # type: ignore
else: else:
logger.warning(f"Music stream {name} not found") logger.warning(f"Music stream {name} not found")
@@ -366,15 +364,15 @@ class AudioEngine:
"""Check if a music stream needs updating (buffers need refilling)""" """Check if a music stream needs updating (buffers need refilling)"""
if name in self.music_streams: if name in self.music_streams:
music = self.music_streams[name] music = self.music_streams[name]
return self.lib.music_stream_needs_update(music) # type: ignore return lib.music_stream_needs_update(music) # type: ignore
return False return False
def update_music_stream(self, name: str) -> None: def update_music_stream(self, name: str) -> None:
"""Update a music stream (only if buffers need refilling)""" """Update a music stream (only if buffers need refilling)"""
if name in self.music_streams: if name in self.music_streams:
music = self.music_streams[name] music = self.music_streams[name]
if self.lib.music_stream_needs_update(music): # type: ignore if lib.music_stream_needs_update(music): # type: ignore
self.lib.update_music_stream(music) # type: ignore lib.update_music_stream(music) # type: ignore
else: else:
logger.warning(f"Music stream {name} not found") logger.warning(f"Music stream {name} not found")
@@ -382,7 +380,7 @@ class AudioEngine:
"""Get the time length of a music stream""" """Get the time length of a music stream"""
if name in self.music_streams: if name in self.music_streams:
music = self.music_streams[name] music = self.music_streams[name]
return self.lib.get_music_time_length(music) # type: ignore return lib.get_music_time_length(music) # type: ignore
else: else:
logger.warning(f"Music stream {name} not found") logger.warning(f"Music stream {name} not found")
return 0.0 return 0.0
@@ -391,7 +389,7 @@ class AudioEngine:
"""Get the time played of a music stream""" """Get the time played of a music stream"""
if name in self.music_streams: if name in self.music_streams:
music = self.music_streams[name] music = self.music_streams[name]
return self.lib.get_music_time_played(music) # type: ignore return lib.get_music_time_played(music) # type: ignore
else: else:
logger.warning(f"Music stream {name} not found") logger.warning(f"Music stream {name} not found")
return 0.0 return 0.0
@@ -400,7 +398,7 @@ class AudioEngine:
"""Set the volume of a music stream""" """Set the volume of a music stream"""
if name in self.music_streams: if name in self.music_streams:
music = self.music_streams[name] music = self.music_streams[name]
self.lib.set_music_volume(music, volume) # type: ignore lib.set_music_volume(music, volume) # type: ignore
else: else:
logger.warning(f"Music stream {name} not found") logger.warning(f"Music stream {name} not found")
@@ -408,7 +406,7 @@ class AudioEngine:
"""Check if a music stream is playing""" """Check if a music stream is playing"""
if name in self.music_streams: if name in self.music_streams:
music = self.music_streams[name] music = self.music_streams[name]
return self.lib.is_music_stream_playing(music) # type: ignore return lib.is_music_stream_playing(music) # type: ignore
else: else:
logger.warning(f"Music stream {name} not found") logger.warning(f"Music stream {name} not found")
return False return False
@@ -417,7 +415,7 @@ class AudioEngine:
"""Stop a music stream""" """Stop a music stream"""
if name in self.music_streams: if name in self.music_streams:
music = self.music_streams[name] music = self.music_streams[name]
self.lib.stop_music_stream(music) # type: ignore lib.stop_music_stream(music) # type: ignore
else: else:
logger.warning(f"Music stream {name} not found") logger.warning(f"Music stream {name} not found")
@@ -425,7 +423,7 @@ class AudioEngine:
"""Unload a music stream""" """Unload a music stream"""
if name in self.music_streams: if name in self.music_streams:
music = self.music_streams[name] music = self.music_streams[name]
self.lib.unload_music_stream(music) # type: ignore lib.unload_music_stream(music) # type: ignore
del self.music_streams[name] del self.music_streams[name]
else: else:
logger.warning(f"Music stream {name} not found") logger.warning(f"Music stream {name} not found")
@@ -439,76 +437,10 @@ class AudioEngine:
"""Seek a music stream to a specific position""" """Seek a music stream to a specific position"""
if name in self.music_streams: if name in self.music_streams:
music = self.music_streams[name] music = self.music_streams[name]
self.lib.seek_music_stream(music, position) # type: ignore lib.seek_music_stream(music, position) # type: ignore
else:
logger.warning(f"Music stream {name} not found")
class AudioEngineLegacy(AudioEngine):
def __init__(self, device_type: int, sample_rate: float, buffer_size: int,
volume_presets: VolumeConfig, sounds_path: Path | None = None):
super().__init__(device_type, sample_rate, buffer_size, volume_presets, sounds_path)
self.lib = ray
def set_log_level(self, level: int):
pass
def list_host_apis(self):
"""Prints a list of available host APIs to the console"""
pass
def get_host_api_name(self, api_id: int) -> str:
"""Returns the name of the host API with the given ID"""
return ''
def init_audio_device(self) -> bool:
"""Initialize the audio device"""
try:
self.lib.init_audio_device()
self.audio_device_ready = self.lib.is_audio_device_ready()
file_path_str = str(self.sounds_path / 'don.wav')
self.don = self.lib.load_sound(file_path_str)
file_path_str = str(self.sounds_path / 'ka.wav')
self.kat = self.lib.load_sound(file_path_str)
if self.audio_device_ready:
logger.info("Audio device initialized successfully")
return self.audio_device_ready
except Exception as e:
logger.error(f"Failed to initialize audio device: {e}")
return False
def load_sound(self, file_path: Path, name: str) -> str:
"""Load a sound file and return sound ID"""
try:
sound = self.lib.load_sound(str(file_path))
if self.lib.is_sound_valid(sound):
self.sounds[name] = sound
return name
else:
logger.error(f"Failed to load sound: {file_path}")
return ""
except Exception as e:
logger.error(f"Error loading sound {file_path}: {e}")
return ""
def load_music_stream(self, file_path: Path, name: str) -> str:
"""Load a music stream and return music ID"""
music = self.lib.load_music_stream(str(file_path))
if self.lib.is_music_valid(music):
self.music_streams[name] = music
logger.info(f"Loaded music stream from {file_path} as {name}")
return name
else:
logger.error(f"Failed to load music: {file_path}")
return ""
def update_music_stream(self, name: str) -> None:
"""Update a music stream (only if buffers need refilling)"""
if name in self.music_streams:
music = self.music_streams[name]
self.lib.update_music_stream(music)
else: else:
logger.warning(f"Music stream {name} not found") logger.warning(f"Music stream {name} not found")
# Create the global audio instance # Create the global audio instance
audio = AudioEngineLegacy(get_config()["audio"]["device_type"], get_config()["audio"]["sample_rate"], get_config()["audio"]["buffer_size"], get_config()["volume"]) audio = AudioEngine(get_config()["audio"]["device_type"], get_config()["audio"]["sample_rate"], get_config()["audio"]["buffer_size"], get_config()["volume"])
audio.set_master_volume(0.75) audio.set_master_volume(0.75)

View File

@@ -26,6 +26,7 @@ class Background:
"IMAS_CG": (libs.bg_collabs.imas.Background, 'background/collab/imas_cg', 3), "IMAS_CG": (libs.bg_collabs.imas.Background, 'background/collab/imas_cg', 3),
"IMAS_ML": (libs.bg_collabs.imas.Background, 'background/collab/imas_ml', 3), "IMAS_ML": (libs.bg_collabs.imas.Background, 'background/collab/imas_ml', 3),
"IMAS_SIDEM": (libs.bg_collabs.imas_sidem.Background, 'background/collab/imas_sidem', 3), "IMAS_SIDEM": (libs.bg_collabs.imas_sidem.Background, 'background/collab/imas_sidem', 3),
"FUNASSYI": (libs.bg_collabs.funassyi.Background, 'background/collab/funassyi', 5),
"DAN": (libs.bg_collabs.dan.Background, 'background/collab/dan', 1), "DAN": (libs.bg_collabs.dan.Background, 'background/collab/dan', 1),
"PRACTICE": (libs.bg_collabs.practice.Background, 'background/collab/practice', 1) "PRACTICE": (libs.bg_collabs.practice.Background, 'background/collab/practice', 1)
} }

View File

@@ -6,3 +6,4 @@ from . import imas
from . import dan from . import dan
from . import imas_sidem from . import imas_sidem
from . import practice from . import practice
from . import funassyi

View File

@@ -0,0 +1,66 @@
from libs.bg_objects.bg_fever import BGFeverBase
from libs.bg_objects.bg_normal import BGNormalBase
from libs.bg_objects.chibi import ChibiController
from libs.bg_objects.dancer import BaseDancer, BaseDancerGroup
from libs.bg_objects.don_bg import DonBG4
from libs.bg_objects.renda import RendaController
from libs.bg_objects.fever import Fever0
from libs.bg_objects.footer import Footer
from libs.global_data import PlayerNum
from libs.texture import TextureWrapper
class Background:
def __init__(self, tex: TextureWrapper, player_num: PlayerNum, bpm: float, path: str, max_dancers: int):
self.tex_wrapper = tex
self.max_dancers = max_dancers
self.don_bg = DonBG4(tex, 0, player_num, path)
self.bg_normal = BGNormalBase(self.tex_wrapper, 0, path)
self.bg_fever = BGFever(self.tex_wrapper, 0, path)
self.footer = Footer(self.tex_wrapper, 2)
self.fever = Fever0(self.tex_wrapper, 0, bpm)
self.dancer = DancerGroup(self.tex_wrapper, 0, bpm, max_dancers, path)
self.renda = RendaController(self.tex_wrapper, 0)
self.chibi = ChibiController(self.tex_wrapper, 0, bpm, path)
class DancerGroup(BaseDancerGroup):
def __init__(self, tex: TextureWrapper, index: int, bpm: float, max_dancers: int, path: str):
self.name = 'dancer_' + str(index)
self.active_count = 0
tex.load_zip(path, f'dancer/{self.name}')
self.spawn_positions = [2, 1, 3, 0, 4]
self.active_dancers = [None] * max_dancers
self.dancers = [BaseDancer(self.name, 0, bpm, tex),
BaseDancer(self.name, 1, bpm, tex),
BaseDancer(self.name, 2, bpm, tex),
BaseDancer(self.name, 3, bpm, tex),
BaseDancer(self.name, 4, bpm, tex)]
self.add_dancer()
class BGFever(BGFeverBase):
def __init__(self, tex: TextureWrapper, index: int, path: str):
super().__init__(tex, index, path)
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.start()
self.bg_texture_move_up.start()
def update(self, current_time_ms: float):
self.bg_texture_move_down.update(current_time_ms)
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.horizontal_move.restart()
if self.transitioned:
self.horizontal_move.update(current_time_ms)
def draw(self, tex: TextureWrapper):
y = self.bg_texture_move_down.attribute - self.bg_texture_move_up.attribute
tex.draw_texture(self.name, 'background', y=y)
tex.draw_texture(self.name, 'overlay', x=-self.horizontal_move.attribute, y=y)
tex.draw_texture(self.name, 'overlay', x=tex.textures[self.name]['overlay'].width - self.horizontal_move.attribute, y=y)

View File

@@ -1,3 +1,4 @@
from libs.animation import Animation
from libs.global_data import PlayerNum from libs.global_data import PlayerNum
from libs.texture import TextureWrapper from libs.texture import TextureWrapper
@@ -14,7 +15,8 @@ class DonBGBase:
def __init__(self, tex: TextureWrapper, index: int, player_num: PlayerNum, path: str): def __init__(self, tex: TextureWrapper, index: int, player_num: PlayerNum, path: str):
self.name = f'{index}_{player_num}' self.name = f'{index}_{player_num}'
tex.load_zip(path, f'donbg/{self.name}') tex.load_zip(path, f'donbg/{self.name}')
self.move = tex.get_animation(0) self.move = Animation.create_move(3000, total_distance=-tex.textures[self.name]['background'].width, loop=True)
self.move.start()
self.is_clear = False self.is_clear = False
self.clear_fade = tex.get_animation(1) self.clear_fade = tex.get_animation(1)
@@ -97,7 +99,7 @@ class DonBG4(DonBGBase):
self.overlay_move.update(current_time_ms) self.overlay_move.update(current_time_ms)
def _draw_textures(self, tex: TextureWrapper, fade: float, y: float): def _draw_textures(self, tex: TextureWrapper, fade: float, y: float):
for i in range(int(5 * tex.screen_scale)): for i in range(5):
tex.draw_texture(self.name, 'background', frame=self.is_clear, fade=fade, x=(i*tex.textures[self.name]['background'].width)+self.move.attribute, y=y) tex.draw_texture(self.name, 'background', frame=self.is_clear, fade=fade, x=(i*tex.textures[self.name]['background'].width)+self.move.attribute, y=y)
tex.draw_texture(self.name, 'overlay', frame=self.is_clear, fade=fade, x=(i*tex.textures[self.name]['overlay'].width)+self.move.attribute, y=self.overlay_move.attribute+y) tex.draw_texture(self.name, 'overlay', frame=self.is_clear, fade=fade, x=(i*tex.textures[self.name]['overlay'].width)+self.move.attribute, y=self.overlay_move.attribute+y)