mirror of
https://github.com/Yonokid/PyTaiko.git
synced 2026-02-04 11:40:13 +01:00
add don chan and the likes
This commit is contained in:
@@ -51,8 +51,6 @@ class Background:
|
||||
self.renda.add_renda()
|
||||
|
||||
def update(self, current_time_ms: float, bpm: float, gauge):
|
||||
is_clear = gauge.gauge_length > gauge.clear_start[min(gauge.difficulty, 3)]
|
||||
is_rainbow = gauge.gauge_length == gauge.gauge_max
|
||||
clear_threshold = gauge.clear_start[min(gauge.difficulty, 3)]
|
||||
if gauge.gauge_length < clear_threshold:
|
||||
current_milestone = min(self.max_dancers - 1, int(gauge.gauge_length / (clear_threshold / self.max_dancers)))
|
||||
@@ -61,12 +59,12 @@ class Background:
|
||||
if current_milestone > self.last_milestone and current_milestone < self.max_dancers:
|
||||
self.dancer.add_dancer()
|
||||
self.last_milestone = current_milestone
|
||||
if not self.is_clear and is_clear:
|
||||
if not self.is_clear and gauge.is_clear:
|
||||
self.bg_fever.start()
|
||||
if not self.is_rainbow and is_rainbow and self.fever is not None:
|
||||
if not self.is_rainbow and gauge.is_rainbow and self.fever is not None:
|
||||
self.fever.start()
|
||||
self.is_clear = is_clear
|
||||
self.is_rainbow = is_rainbow
|
||||
self.is_clear = gauge.is_clear
|
||||
self.is_rainbow = gauge.is_rainbow
|
||||
self.don_bg.update(current_time_ms, self.is_clear)
|
||||
self.bg_normal.update(current_time_ms)
|
||||
self.bg_fever.update(current_time_ms)
|
||||
|
||||
74
libs/chara_2d.py
Normal file
74
libs/chara_2d.py
Normal file
@@ -0,0 +1,74 @@
|
||||
from libs.animation import Animation
|
||||
from libs.utils import global_data
|
||||
|
||||
class Chara2D:
|
||||
def __init__(self, index: int, bpm: float, path: str = 'chara'):
|
||||
self.name = "chara_" + str(index)
|
||||
self.tex = global_data.tex
|
||||
self.anims = dict()
|
||||
self.bpm = bpm
|
||||
self.current_anim = 'normal'
|
||||
self.past_anim = 'normal'
|
||||
self.is_rainbow = False
|
||||
self.is_clear = False
|
||||
self.temp_anims = {'10_combo','10_combo_max', 'soul_in', 'clear_in', 'balloon_pop', 'balloon_miss'}
|
||||
for name in self.tex.textures[self.name]:
|
||||
tex_list = self.tex.textures[self.name][name].texture
|
||||
keyframe_len = len(tex_list) if isinstance(tex_list, list) else 1
|
||||
if index == 0:
|
||||
duration = 2250*2 / self.bpm
|
||||
else:
|
||||
duration = 2250 / self.bpm
|
||||
total_duration = duration * keyframe_len
|
||||
keyframes = [i for i in range(keyframe_len)]
|
||||
textures = [[duration*i, duration*(i+1), index] for i, index in enumerate(keyframes)]
|
||||
self.anims[name] = Animation.create_texture_change(total_duration, textures=textures)
|
||||
self.anims[name].start()
|
||||
|
||||
def set_animation(self, name: str):
|
||||
if name == self.current_anim:
|
||||
return
|
||||
if self.current_anim in self.temp_anims:
|
||||
return
|
||||
self.past_anim = self.current_anim
|
||||
if name == 'balloon_pop' or name == 'balloon_miss':
|
||||
self.past_anim = 'normal'
|
||||
if self.is_clear:
|
||||
self.past_anim = 'clear'
|
||||
self.current_anim = name
|
||||
self.anims[name].start()
|
||||
def update(self, current_time_ms: float, bpm: float, is_clear: bool, is_rainbow: bool):
|
||||
if is_rainbow and not self.is_rainbow:
|
||||
self.is_rainbow = True
|
||||
self.set_animation('soul_in')
|
||||
if is_clear and not self.is_clear:
|
||||
self.is_clear = True
|
||||
self.set_animation('clear_in')
|
||||
self.past_anim = 'clear'
|
||||
if bpm != self.bpm:
|
||||
self.bpm = bpm
|
||||
for name in self.tex.textures[self.name]:
|
||||
tex_list = self.tex.textures[self.name][name].texture
|
||||
keyframe_len = len(tex_list) if isinstance(tex_list, list) else 1
|
||||
duration = 2250 / self.bpm
|
||||
total_duration = duration * keyframe_len
|
||||
keyframes = [i for i in range(keyframe_len)]
|
||||
textures = [[duration*i, duration*(i+1), index] for i, index in enumerate(keyframes)]
|
||||
self.anims[name] = Animation.create_texture_change(total_duration, textures=textures)
|
||||
self.anims[name].start()
|
||||
self.anims[self.current_anim] = self.anims[self.current_anim]
|
||||
self.anims[self.current_anim].update(current_time_ms)
|
||||
if self.anims[self.current_anim].is_finished:
|
||||
if self.current_anim in self.temp_anims:
|
||||
self.anims[self.current_anim].reset()
|
||||
self.current_anim = self.past_anim
|
||||
self.anims[self.current_anim].restart()
|
||||
|
||||
def draw(self, x: float = 0, y: float = 0, mirror=False):
|
||||
if self.is_rainbow and self.current_anim not in {'soul_in', 'balloon_pop', 'balloon_popping'}:
|
||||
self.tex.draw_texture(self.name, self.current_anim + '_max', frame=self.anims[self.current_anim].attribute, x=x, y=y)
|
||||
else:
|
||||
if mirror:
|
||||
self.tex.draw_texture(self.name, self.current_anim, frame=self.anims[self.current_anim].attribute, x=x, y=y, mirror='horizontal')
|
||||
else:
|
||||
self.tex.draw_texture(self.name, self.current_anim, frame=self.anims[self.current_anim].attribute, x=x, y=y)
|
||||
@@ -98,6 +98,9 @@ class TextureWrapper:
|
||||
|
||||
def load_zip(self, screen_name: str, subset: str):
|
||||
zip = (self.graphics_path / screen_name / subset).with_suffix('.zip')
|
||||
if screen_name in self.textures and subset in self.textures[screen_name]:
|
||||
print(screen_name, subset)
|
||||
return
|
||||
with zipfile.ZipFile(zip, 'r') as zip_ref:
|
||||
if 'texture.json' not in zip_ref.namelist():
|
||||
raise Exception(f"texture.json file missing from {zip}")
|
||||
|
||||
Reference in New Issue
Block a user