mirror of
https://github.com/Yonokid/PyTaiko.git
synced 2026-02-04 11:40:13 +01:00
add fever bouncers
This commit is contained in:
@@ -3,31 +3,40 @@ import random
|
||||
from libs.bg_objects.bg_fever import BGFever
|
||||
from libs.bg_objects.bg_normal import BGNormal
|
||||
from libs.bg_objects.don_bg import DonBG
|
||||
from libs.bg_objects.fever import Fever
|
||||
from libs.texture import TextureWrapper
|
||||
|
||||
|
||||
class Background:
|
||||
def __init__(self, player_num: int):
|
||||
def __init__(self, player_num: int, bpm: float):
|
||||
self.tex_wrapper = TextureWrapper()
|
||||
self.tex_wrapper.load_animations('background')
|
||||
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, random.randint(0, 3))
|
||||
self.footer = Footer(self.tex_wrapper, random.randint(0, 2))
|
||||
self.fever = Fever.create(self.tex_wrapper, random.randint(0, 3), bpm)
|
||||
self.is_clear = False
|
||||
def update(self, current_time_ms: float, is_clear: bool):
|
||||
self.is_rainbow = False
|
||||
def update(self, current_time_ms: float, bpm: float, is_clear: bool, is_rainbow: bool):
|
||||
if not self.is_clear and is_clear:
|
||||
self.bg_fever.start()
|
||||
if not self.is_rainbow and is_rainbow:
|
||||
self.fever.start()
|
||||
self.is_clear = is_clear
|
||||
self.is_rainbow = is_rainbow
|
||||
self.donbg.update(current_time_ms, self.is_clear)
|
||||
self.bg_normal.update(current_time_ms)
|
||||
self.bg_fever.update(current_time_ms)
|
||||
self.fever.update(current_time_ms, bpm)
|
||||
def draw(self):
|
||||
self.bg_normal.draw(self.tex_wrapper)
|
||||
if self.is_clear:
|
||||
self.bg_fever.draw(self.tex_wrapper)
|
||||
self.footer.draw(self.tex_wrapper)
|
||||
self.donbg.draw(self.tex_wrapper)
|
||||
if self.is_rainbow:
|
||||
self.fever.draw(self.tex_wrapper)
|
||||
|
||||
def unload(self):
|
||||
self.tex_wrapper.unload_textures()
|
||||
|
||||
49
libs/bg_objects/fever.py
Normal file
49
libs/bg_objects/fever.py
Normal file
@@ -0,0 +1,49 @@
|
||||
from libs.animation import Animation
|
||||
from libs.texture import TextureWrapper
|
||||
|
||||
class Fever:
|
||||
|
||||
@staticmethod
|
||||
def create(tex: TextureWrapper, index: int, bpm: float):
|
||||
map = [Fever0, Fever1, Fever2, Fever3]
|
||||
selected_obj = map[index]
|
||||
return selected_obj(tex, index, bpm)
|
||||
|
||||
class BaseFever:
|
||||
def __init__(self, tex: TextureWrapper, index: int, bpm: float):
|
||||
self.name = 'fever_' + str(index)
|
||||
tex.load_zip('background', f'fever/{self.name}')
|
||||
self.bounce_up = Animation.create_move((60000 / bpm) / 2, total_distance=50, ease_out='quadratic')
|
||||
self.bounce_down = Animation.create_move((60000 / bpm) / 2, total_distance=50, ease_in='quadratic', delay=self.bounce_up.duration)
|
||||
|
||||
def start(self):
|
||||
self.bounce_down.start()
|
||||
self.bounce_up.start()
|
||||
|
||||
def update(self, current_time_ms: int, bpm: float):
|
||||
self.bounce_up.update(current_time_ms)
|
||||
self.bounce_down.update(current_time_ms)
|
||||
if self.bounce_down.is_finished:
|
||||
self.bounce_up.duration = (60000 / bpm) / 2
|
||||
self.bounce_down.duration = (60000 / bpm) / 2
|
||||
self.bounce_up.restart()
|
||||
self.bounce_down.restart()
|
||||
|
||||
class Fever0(BaseFever):
|
||||
def draw(self, tex: TextureWrapper):
|
||||
tex.draw_texture(self.name, 'overlay_l', y=self.bounce_down.attribute-self.bounce_up.attribute)
|
||||
tex.draw_texture(self.name, 'overlay_r', y=self.bounce_down.attribute-self.bounce_up.attribute)
|
||||
|
||||
class Fever1(BaseFever):
|
||||
def draw(self, tex: TextureWrapper):
|
||||
tex.draw_texture(self.name, 'overlay_l', y=self.bounce_down.attribute-self.bounce_up.attribute)
|
||||
tex.draw_texture(self.name, 'overlay_r', y=self.bounce_down.attribute-self.bounce_up.attribute)
|
||||
|
||||
class Fever2(BaseFever):
|
||||
def draw(self, tex: TextureWrapper):
|
||||
tex.draw_texture(self.name, 'overlay_l', y=self.bounce_down.attribute-self.bounce_up.attribute)
|
||||
tex.draw_texture(self.name, 'overlay_r', y=self.bounce_down.attribute-self.bounce_up.attribute)
|
||||
|
||||
class Fever3(BaseFever):
|
||||
def draw(self, tex: TextureWrapper):
|
||||
tex.draw_texture(self.name, 'overlay', y=self.bounce_down.attribute-self.bounce_up.attribute)
|
||||
Reference in New Issue
Block a user