mirror of
https://github.com/Yonokid/PyTaiko.git
synced 2026-02-04 11:40:13 +01:00
Compare commits
3 Commits
legacy-aud
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c5a3f1e9e5 | ||
|
|
46ddce2443 | ||
|
|
ae2702b3dd |
15
PyTaiko.py
15
PyTaiko.py
@@ -47,6 +47,7 @@ from scenes.two_player.result import TwoPlayerResultScreen
|
||||
from scenes.two_player.song_select import TwoPlayerSongSelectScreen
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
'''
|
||||
DISCORD_APP_ID = '1451423960401973353'
|
||||
try:
|
||||
RPC = Presence(DISCORD_APP_ID)
|
||||
@@ -55,6 +56,7 @@ try:
|
||||
except Exception as e:
|
||||
discord_connected = False
|
||||
logger.warning(f"Could not connect to Discord: {e}")
|
||||
'''
|
||||
|
||||
class Screens:
|
||||
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}"
|
||||
else:
|
||||
details = "Idling"
|
||||
'''
|
||||
RPC.update(
|
||||
state=f"In Screen {current_screen}",
|
||||
details=details,
|
||||
large_text="PyTaiko",
|
||||
start=get_current_ms()/1000,
|
||||
buttons=[{"label": "Play Now", "url": "https://github.com/Yonokid/PyTaiko"}]
|
||||
)
|
||||
)'''
|
||||
|
||||
def draw_fps(last_fps: int):
|
||||
curr_fps = ray.GetFPS()
|
||||
@@ -400,9 +403,9 @@ def main():
|
||||
|
||||
while not ray.WindowShouldClose():
|
||||
current_time = get_current_ms()
|
||||
if discord_connected and current_time > last_discord_check + 1000:
|
||||
check_discord_heartbeat(current_screen)
|
||||
last_discord_check = current_time
|
||||
#if discord_connected and current_time > last_discord_check + 1000:
|
||||
#check_discord_heartbeat(current_screen)
|
||||
#last_discord_check = current_time
|
||||
|
||||
if ray.IsKeyPressed(global_data.config["keys"]["fullscreen_key"]):
|
||||
ray.ToggleFullscreen()
|
||||
@@ -444,8 +447,8 @@ def main():
|
||||
|
||||
ray.CloseWindow()
|
||||
audio.close_audio_device()
|
||||
if discord_connected:
|
||||
RPC.close()
|
||||
#if discord_connected:
|
||||
#RPC.close()
|
||||
global_tex.unload_textures()
|
||||
screen_mapping[current_screen].on_screen_end("LOADING")
|
||||
logger.info("Window closed and audio device shut down")
|
||||
|
||||
Submodule Skins/PyTaikoGreen updated: 8cac9f3e0b...ff7f52ef4f
176
libs/audio.py
176
libs/audio.py
@@ -1,6 +1,5 @@
|
||||
import logging
|
||||
import platform
|
||||
import pyray as ray
|
||||
from pathlib import Path
|
||||
|
||||
import cffi
|
||||
@@ -133,7 +132,6 @@ class AudioEngine:
|
||||
self.music_streams = {}
|
||||
self.audio_device_ready = False
|
||||
self.volume_presets = volume_presets
|
||||
self.lib = lib
|
||||
|
||||
if sounds_path is None:
|
||||
self.sounds_path = Path(f"Skins/{get_config()['paths']['skin']}/Sounds")
|
||||
@@ -141,15 +139,15 @@ class AudioEngine:
|
||||
self.sounds_path = sounds_path
|
||||
|
||||
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):
|
||||
"""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:
|
||||
"""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:
|
||||
return ""
|
||||
result = ffi.string(result)
|
||||
@@ -160,12 +158,12 @@ class AudioEngine:
|
||||
def init_audio_device(self) -> bool:
|
||||
"""Initialize the audio device"""
|
||||
try:
|
||||
self.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
|
||||
lib.init_audio_device(self.device_type, self.target_sample_rate, self.buffer_size) # 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')
|
||||
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')
|
||||
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:
|
||||
logger.info("Audio device initialized successfully")
|
||||
return self.audio_device_ready
|
||||
@@ -182,9 +180,9 @@ class AudioEngine:
|
||||
for music_id in list(self.music_streams.keys()):
|
||||
self.unload_music_stream(music_id)
|
||||
|
||||
self.lib.unload_sound(self.don) # type: ignore
|
||||
self.lib.unload_sound(self.kat) # type: ignore
|
||||
self.lib.close_audio_device() # type: ignore
|
||||
lib.unload_sound(self.don) # type: ignore
|
||||
lib.unload_sound(self.kat) # type: ignore
|
||||
lib.close_audio_device() # type: ignore
|
||||
self.audio_device_ready = False
|
||||
logger.info("Audio device closed")
|
||||
except Exception as e:
|
||||
@@ -192,15 +190,15 @@ class AudioEngine:
|
||||
|
||||
def is_audio_device_ready(self) -> bool:
|
||||
"""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:
|
||||
"""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:
|
||||
"""Get master volume"""
|
||||
return self.lib.get_master_volume() # type: ignore
|
||||
return lib.get_master_volume() # type: ignore
|
||||
|
||||
# Sound management
|
||||
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')
|
||||
else:
|
||||
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')
|
||||
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
|
||||
return name
|
||||
else:
|
||||
@@ -230,7 +228,7 @@ class AudioEngine:
|
||||
def unload_sound(self, name: str) -> None:
|
||||
"""Unload a sound by name"""
|
||||
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]
|
||||
else:
|
||||
logger.warning(f"Sound {name} not found")
|
||||
@@ -265,41 +263,41 @@ class AudioEngine:
|
||||
"""Play a sound"""
|
||||
if name == 'don':
|
||||
if volume_preset:
|
||||
self.lib.set_sound_volume(self.don, self.volume_presets[volume_preset]) # type: ignore
|
||||
self.lib.play_sound(self.don) # type: ignore
|
||||
lib.set_sound_volume(self.don, self.volume_presets[volume_preset]) # type: ignore
|
||||
lib.play_sound(self.don) # type: ignore
|
||||
elif name == 'kat':
|
||||
if volume_preset:
|
||||
self.lib.set_sound_volume(self.kat, self.volume_presets[volume_preset]) # type: ignore
|
||||
self.lib.play_sound(self.kat) # type: ignore
|
||||
lib.set_sound_volume(self.kat, self.volume_presets[volume_preset]) # type: ignore
|
||||
lib.play_sound(self.kat) # type: ignore
|
||||
elif name in self.sounds:
|
||||
sound = self.sounds[name]
|
||||
if volume_preset:
|
||||
self.lib.set_sound_volume(sound, self.volume_presets[volume_preset]) # type: ignore
|
||||
self.lib.play_sound(sound) # type: ignore
|
||||
lib.set_sound_volume(sound, self.volume_presets[volume_preset]) # type: ignore
|
||||
lib.play_sound(sound) # type: ignore
|
||||
else:
|
||||
logger.warning(f"Sound {name} not found")
|
||||
|
||||
def stop_sound(self, name: str) -> None:
|
||||
"""Stop a sound"""
|
||||
if name == 'don':
|
||||
self.lib.stop_sound(self.don) # type: ignore
|
||||
lib.stop_sound(self.don) # type: ignore
|
||||
elif name == 'kat':
|
||||
self.lib.stop_sound(self.kat) # type: ignore
|
||||
lib.stop_sound(self.kat) # type: ignore
|
||||
if name in self.sounds:
|
||||
sound = self.sounds[name]
|
||||
self.lib.stop_sound(sound) # type: ignore
|
||||
lib.stop_sound(sound) # type: ignore
|
||||
else:
|
||||
logger.warning(f"Sound {name} not found")
|
||||
|
||||
def is_sound_playing(self, name: str) -> bool:
|
||||
"""Check if a sound is playing"""
|
||||
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':
|
||||
return self.lib.is_sound_playing(self.kat) # type: ignore
|
||||
return lib.is_sound_playing(self.kat) # type: ignore
|
||||
if name in self.sounds:
|
||||
sound = self.sounds[name]
|
||||
return self.lib.is_sound_playing(sound) # type: ignore
|
||||
return lib.is_sound_playing(sound) # type: ignore
|
||||
else:
|
||||
logger.warning(f"Sound {name} not found")
|
||||
return False
|
||||
@@ -307,24 +305,24 @@ class AudioEngine:
|
||||
def set_sound_volume(self, name: str, volume: float) -> None:
|
||||
"""Set the volume of a specific sound"""
|
||||
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':
|
||||
self.lib.set_sound_volume(self.kat, volume) # type: ignore
|
||||
lib.set_sound_volume(self.kat, volume) # type: ignore
|
||||
elif name in self.sounds:
|
||||
sound = self.sounds[name]
|
||||
self.lib.set_sound_volume(sound, volume) # type: ignore
|
||||
lib.set_sound_volume(sound, volume) # type: ignore
|
||||
else:
|
||||
logger.warning(f"Sound {name} not found")
|
||||
|
||||
def set_sound_pan(self, name: str, pan: float) -> None:
|
||||
"""Set the pan of a specific sound"""
|
||||
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':
|
||||
self.lib.set_sound_pan(self.kat, pan) # type: ignore
|
||||
lib.set_sound_pan(self.kat, pan) # type: ignore
|
||||
elif name in self.sounds:
|
||||
sound = self.sounds[name]
|
||||
self.lib.set_sound_pan(sound, pan) # type: ignore
|
||||
lib.set_sound_pan(sound, pan) # type: ignore
|
||||
else:
|
||||
logger.warning(f"Sound {name} not found")
|
||||
|
||||
@@ -337,13 +335,13 @@ class AudioEngine:
|
||||
else:
|
||||
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')
|
||||
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
|
||||
logger.info(f"Loaded music stream from {file_path} as {name}")
|
||||
return name
|
||||
@@ -355,10 +353,10 @@ class AudioEngine:
|
||||
"""Play a music stream"""
|
||||
if name in self.music_streams:
|
||||
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:
|
||||
self.lib.set_music_volume(music, self.volume_presets[volume_preset]) # type: ignore
|
||||
self.lib.play_music_stream(music) # type: ignore
|
||||
lib.set_music_volume(music, self.volume_presets[volume_preset]) # type: ignore
|
||||
lib.play_music_stream(music) # type: ignore
|
||||
else:
|
||||
logger.warning(f"Music stream {name} not found")
|
||||
|
||||
@@ -366,15 +364,15 @@ class AudioEngine:
|
||||
"""Check if a music stream needs updating (buffers need refilling)"""
|
||||
if name in self.music_streams:
|
||||
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
|
||||
|
||||
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]
|
||||
if self.lib.music_stream_needs_update(music): # type: ignore
|
||||
self.lib.update_music_stream(music) # type: ignore
|
||||
if lib.music_stream_needs_update(music): # type: ignore
|
||||
lib.update_music_stream(music) # type: ignore
|
||||
else:
|
||||
logger.warning(f"Music stream {name} not found")
|
||||
|
||||
@@ -382,7 +380,7 @@ class AudioEngine:
|
||||
"""Get the time length of a music stream"""
|
||||
if name in self.music_streams:
|
||||
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:
|
||||
logger.warning(f"Music stream {name} not found")
|
||||
return 0.0
|
||||
@@ -391,7 +389,7 @@ class AudioEngine:
|
||||
"""Get the time played of a music stream"""
|
||||
if name in self.music_streams:
|
||||
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:
|
||||
logger.warning(f"Music stream {name} not found")
|
||||
return 0.0
|
||||
@@ -400,7 +398,7 @@ class AudioEngine:
|
||||
"""Set the volume of a music stream"""
|
||||
if name in self.music_streams:
|
||||
music = self.music_streams[name]
|
||||
self.lib.set_music_volume(music, volume) # type: ignore
|
||||
lib.set_music_volume(music, volume) # type: ignore
|
||||
else:
|
||||
logger.warning(f"Music stream {name} not found")
|
||||
|
||||
@@ -408,7 +406,7 @@ class AudioEngine:
|
||||
"""Check if a music stream is playing"""
|
||||
if name in self.music_streams:
|
||||
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:
|
||||
logger.warning(f"Music stream {name} not found")
|
||||
return False
|
||||
@@ -417,7 +415,7 @@ class AudioEngine:
|
||||
"""Stop a music stream"""
|
||||
if name in self.music_streams:
|
||||
music = self.music_streams[name]
|
||||
self.lib.stop_music_stream(music) # type: ignore
|
||||
lib.stop_music_stream(music) # type: ignore
|
||||
else:
|
||||
logger.warning(f"Music stream {name} not found")
|
||||
|
||||
@@ -425,7 +423,7 @@ class AudioEngine:
|
||||
"""Unload a music stream"""
|
||||
if name in self.music_streams:
|
||||
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]
|
||||
else:
|
||||
logger.warning(f"Music stream {name} not found")
|
||||
@@ -439,76 +437,10 @@ class AudioEngine:
|
||||
"""Seek a music stream to a specific position"""
|
||||
if name in self.music_streams:
|
||||
music = self.music_streams[name]
|
||||
self.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)
|
||||
lib.seek_music_stream(music, position) # type: ignore
|
||||
else:
|
||||
logger.warning(f"Music stream {name} not found")
|
||||
|
||||
# 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)
|
||||
|
||||
@@ -26,6 +26,7 @@ class Background:
|
||||
"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_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),
|
||||
"PRACTICE": (libs.bg_collabs.practice.Background, 'background/collab/practice', 1)
|
||||
}
|
||||
|
||||
@@ -6,3 +6,4 @@ from . import imas
|
||||
from . import dan
|
||||
from . import imas_sidem
|
||||
from . import practice
|
||||
from . import funassyi
|
||||
|
||||
66
libs/bg_collabs/funassyi.py
Normal file
66
libs/bg_collabs/funassyi.py
Normal 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)
|
||||
@@ -1,3 +1,4 @@
|
||||
from libs.animation import Animation
|
||||
from libs.global_data import PlayerNum
|
||||
from libs.texture import TextureWrapper
|
||||
|
||||
@@ -14,7 +15,8 @@ class DonBGBase:
|
||||
def __init__(self, tex: TextureWrapper, index: int, player_num: PlayerNum, path: str):
|
||||
self.name = f'{index}_{player_num}'
|
||||
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.clear_fade = tex.get_animation(1)
|
||||
|
||||
@@ -97,7 +99,7 @@ class DonBG4(DonBGBase):
|
||||
self.overlay_move.update(current_time_ms)
|
||||
|
||||
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, 'overlay', frame=self.is_clear, fade=fade, x=(i*tex.textures[self.name]['overlay'].width)+self.move.attribute, y=self.overlay_move.attribute+y)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user