mirror of
https://github.com/Yonokid/PyTaiko.git
synced 2026-02-04 11:40:13 +01:00
add custom background implementation and A3 collab
This commit is contained in:
@@ -9,15 +9,15 @@ from libs.texture import TextureWrapper
|
||||
class BGFever:
|
||||
|
||||
@staticmethod
|
||||
def create(tex: TextureWrapper, index: int):
|
||||
def create(tex: TextureWrapper, index: int, path: str = 'background'):
|
||||
map = [BGFever1, BGFever2, BGFever3, BGFever4]
|
||||
selected_obj = map[index]
|
||||
return selected_obj(tex, index)
|
||||
return selected_obj(tex, index, path)
|
||||
|
||||
class BGFeverBase:
|
||||
def __init__(self, tex: TextureWrapper, index: int):
|
||||
def __init__(self, tex: TextureWrapper, index: int, path: str):
|
||||
self.name = 'bg_fever_' + str(index)
|
||||
tex.load_zip('background', f'bg_fever/{self.name}')
|
||||
tex.load_zip(path, f'bg_fever/{self.name}')
|
||||
self.transitioned = False
|
||||
|
||||
class BGFever1(BGFeverBase):
|
||||
@@ -29,8 +29,8 @@ class BGFever1(BGFeverBase):
|
||||
self.expansion.update(current_time_ms)
|
||||
def draw(self, tex: TextureWrapper, name: str, x: int, frame: int):
|
||||
tex.draw_texture(name, 'background', frame=frame, x=x, y2=-360+self.expansion.attribute, y=360+(180-self.expansion.attribute/2))
|
||||
def __init__(self, tex: TextureWrapper, index: int):
|
||||
super().__init__(tex, index)
|
||||
def __init__(self, tex: TextureWrapper, index: int, path):
|
||||
super().__init__(tex, index, path)
|
||||
self.wait = 0
|
||||
self.bg_tiles: list[BGFever1.Tile] = []
|
||||
self.corner_move_up = tex.get_animation(29)
|
||||
@@ -104,8 +104,8 @@ class BGFever1(BGFeverBase):
|
||||
tex.draw_texture(self.name, 'overlay', y=self.overlay_move_up.attribute-self.overlay_move_down.attribute)
|
||||
|
||||
class BGFever2(BGFeverBase):
|
||||
def __init__(self, tex: TextureWrapper, index: int):
|
||||
super().__init__(tex, index)
|
||||
def __init__(self, tex: TextureWrapper, index: int, path: str):
|
||||
super().__init__(tex, index, path)
|
||||
self.fadein = tex.get_animation(19)
|
||||
self.bg_texture_change = tex.get_animation(20)
|
||||
self.ship_rotation = tex.get_animation(21)
|
||||
@@ -137,8 +137,8 @@ class BGFever2(BGFeverBase):
|
||||
tex.draw_texture(self.name, 'ship', x=origin.x, y=origin.y + self.move_in.attribute-self.move_out.attribute, origin=origin, rotation=self.ship_rotation.attribute*100, center=True)
|
||||
|
||||
class BGFever3(BGFeverBase):
|
||||
def __init__(self, tex: TextureWrapper, index: int):
|
||||
super().__init__(tex, index)
|
||||
def __init__(self, tex: TextureWrapper, index: int, path: str):
|
||||
super().__init__(tex, index, path)
|
||||
self.fadein = tex.get_animation(19)
|
||||
self.move_in = tex.get_animation(24)
|
||||
self.footer_move_up = tex.get_animation(26)
|
||||
@@ -215,8 +215,8 @@ class BGFever3(BGFeverBase):
|
||||
tex.draw_texture(self.name, 'bird', frame=self.bird_tc.attribute, index=1, x=-self.move_in.attribute)
|
||||
|
||||
class BGFever4(BGFeverBase):
|
||||
def __init__(self, tex: TextureWrapper, index: int):
|
||||
super().__init__(tex, index)
|
||||
def __init__(self, tex: TextureWrapper, index: int, path: str):
|
||||
super().__init__(tex, index, path)
|
||||
self.vertical_move = tex.get_animation(15)
|
||||
self.horizontal_move = tex.get_animation(16)
|
||||
self.bg_texture_move_down = tex.get_animation(17)
|
||||
|
||||
@@ -7,19 +7,19 @@ from libs.texture import TextureWrapper
|
||||
class BGNormal:
|
||||
|
||||
@staticmethod
|
||||
def create(tex: TextureWrapper, index: int):
|
||||
def create(tex: TextureWrapper, index: int, path: str = 'background'):
|
||||
map = [BGNormal1, BGNormal2, BGNormal3, BGNormal4, BGNormal5]
|
||||
selected_obj = map[index]
|
||||
return selected_obj(tex, index)
|
||||
return selected_obj(tex, index, path)
|
||||
|
||||
class BGNormalBase:
|
||||
def __init__(self, tex: TextureWrapper, index: int):
|
||||
def __init__(self, tex: TextureWrapper, index: int, path: str):
|
||||
self.name = "bg_" + str(index)
|
||||
tex.load_zip('background', f'bg_normal/{self.name}')
|
||||
tex.load_zip(path, f'bg_normal/{self.name}')
|
||||
|
||||
class BGNormal1(BGNormalBase):
|
||||
def __init__(self, tex: TextureWrapper, index: int):
|
||||
super().__init__(tex, index)
|
||||
def __init__(self, tex: TextureWrapper, index: int, path: str):
|
||||
super().__init__(tex, index, path)
|
||||
self.flicker = tex.get_animation(9)
|
||||
def update(self, current_time_ms: float):
|
||||
self.flicker.update(current_time_ms)
|
||||
@@ -28,8 +28,8 @@ class BGNormal1(BGNormalBase):
|
||||
tex.draw_texture(self.name, 'overlay', fade=self.flicker.attribute)
|
||||
|
||||
class BGNormal2(BGNormalBase):
|
||||
def __init__(self, tex: TextureWrapper, index: int):
|
||||
super().__init__(tex, index)
|
||||
def __init__(self, tex: TextureWrapper, index: int, path: str):
|
||||
super().__init__(tex, index, path)
|
||||
self.flicker = tex.get_animation(9)
|
||||
def update(self, current_time_ms: float):
|
||||
self.flicker.update(current_time_ms)
|
||||
@@ -38,8 +38,8 @@ class BGNormal2(BGNormalBase):
|
||||
tex.draw_texture(self.name, 'overlay', fade=self.flicker.attribute)
|
||||
|
||||
class BGNormal3(BGNormalBase):
|
||||
def __init__(self, tex: TextureWrapper, index: int):
|
||||
super().__init__(tex, index)
|
||||
def __init__(self, tex: TextureWrapper, index: int, path: str):
|
||||
super().__init__(tex, index, path)
|
||||
self.flicker = tex.get_animation(10)
|
||||
def update(self, current_time_ms):
|
||||
self.flicker.update(current_time_ms)
|
||||
@@ -82,8 +82,8 @@ class BGNormal4(BGNormalBase):
|
||||
self.move_y.update(current_time_ms)
|
||||
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)
|
||||
def __init__(self, tex: TextureWrapper, index: int, path: str):
|
||||
super().__init__(tex, index, path)
|
||||
self.flicker = tex.get_animation(11)
|
||||
self.turtle_move = tex.get_animation(12)
|
||||
self.turtle_change = tex.get_animation(13)
|
||||
@@ -108,8 +108,8 @@ class BGNormal4(BGNormalBase):
|
||||
petal.draw(self.name, tex)
|
||||
|
||||
class BGNormal5(BGNormalBase):
|
||||
def __init__(self, tex: TextureWrapper, index: int):
|
||||
super().__init__(tex, index)
|
||||
def __init__(self, tex: TextureWrapper, index: int, path: str):
|
||||
super().__init__(tex, index, path)
|
||||
self.flicker = tex.get_animation(14)
|
||||
def update(self, current_time_ms: float):
|
||||
self.flicker.update(current_time_ms)
|
||||
|
||||
@@ -46,10 +46,14 @@ class BaseChibi:
|
||||
|
||||
class ChibiBad(BaseChibi):
|
||||
def __init__(self, index: int, bpm: float, tex: TextureWrapper):
|
||||
super().__init__(index, bpm, tex)
|
||||
self.bpm = bpm
|
||||
self.index = random.randint(0, 2)
|
||||
self.keyframes = [3, 4]
|
||||
duration = (60000 / self.bpm) / 2
|
||||
self.hori_move = Animation.create_move(duration * 10, total_distance=1280)
|
||||
self.hori_move.start()
|
||||
self.vert_move = Animation.create_move(duration, total_distance=50, reverse_delay=0)
|
||||
self.vert_move.start()
|
||||
self.fade_in = Animation.create_fade(duration, initial_opacity=0.0, final_opacity=1.0)
|
||||
self.fade_in.start()
|
||||
s_keyframes = [0, 1, 2]
|
||||
@@ -131,14 +135,15 @@ class Chibi13(BaseChibi):
|
||||
|
||||
|
||||
class ChibiController:
|
||||
def __init__(self, tex: TextureWrapper, index: int, bpm: float):
|
||||
def __init__(self, tex: TextureWrapper, index: int, bpm: float, path: str = 'background'):
|
||||
self.chibis = set()
|
||||
self.tex = tex
|
||||
self.index = index
|
||||
print(self.index)
|
||||
self.name = 'chibi_' + str(index)
|
||||
self.bpm = bpm
|
||||
tex.load_zip('background', f'chibi/{self.name}')
|
||||
tex.load_zip('background', f'chibi/chibi_bad')
|
||||
tex.load_zip(path, f'chibi/{self.name}')
|
||||
tex.load_zip('background', 'chibi/chibi_bad')
|
||||
|
||||
def add_chibi(self, bad=False):
|
||||
self.chibis.add(Chibi.create(self.index, self.bpm, bad, self.tex))
|
||||
|
||||
@@ -6,13 +6,13 @@ from libs.texture import TextureWrapper
|
||||
class Dancer:
|
||||
|
||||
@staticmethod
|
||||
def create(tex: TextureWrapper, index: int, bpm: float):
|
||||
def create(tex: TextureWrapper, index: int, bpm: float, max_dancers: int = 5, path: str = 'background'):
|
||||
map = [DancerGroup0, DancerGroup0, DancerGroup0, BaseDancerGroup, BaseDancerGroup, BaseDancerGroup,
|
||||
BaseDancerGroup, DancerGroupPoof1, DancerGroupPoof1, BaseDancerGroup, BaseDancerGroup, BaseDancerGroup,
|
||||
DancerGroupPoof2, DancerGroupPoof2, BaseDancerGroup, BaseDancerGroup, DancerGroupPoof2, BaseDancerGroup,
|
||||
BaseDancerGroup, BaseDancerGroup, BaseDancerGroup]
|
||||
selected_obj = map[index]
|
||||
return selected_obj(tex, index, bpm)
|
||||
return selected_obj(tex, index, bpm, max_dancers, path)
|
||||
|
||||
class BaseDancer:
|
||||
def __init__(self, name: str, index: int, bpm: float, tex: TextureWrapper):
|
||||
@@ -129,13 +129,13 @@ class DancerPoof2(DancerPoof):
|
||||
tex.draw_texture(self.name, str(self.index) + '_poof', x=x, frame=self.poof_texture_change.attribute)
|
||||
|
||||
class BaseDancerGroup():
|
||||
def __init__(self, tex: TextureWrapper, index: int, bpm: float):
|
||||
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('background', f'dancer/{self.name}')
|
||||
tex.load_zip(path, f'dancer/{self.name}')
|
||||
# center (2), left (1), right (3), far left (0), far right (4)
|
||||
self.spawn_positions = [2, 1, 3, 0, 4]
|
||||
self.active_dancers = [None] * 5
|
||||
self.active_dancers = [None] * max_dancers
|
||||
dancer_classes = [BaseDancer]
|
||||
tex_set = set()
|
||||
tex_dict = tex.textures['dancer_' + str(index)]
|
||||
@@ -143,7 +143,7 @@ class BaseDancerGroup():
|
||||
if key[0].isdigit():
|
||||
tex_set.add(int(key[0]))
|
||||
self.dancers = []
|
||||
for i in range(5):
|
||||
for i in range(max_dancers):
|
||||
DancerClass = random.choice(dancer_classes)
|
||||
dancer = DancerClass(self.name, i % len(tex_set), bpm, tex)
|
||||
self.dancers.append(dancer)
|
||||
@@ -164,18 +164,30 @@ class BaseDancerGroup():
|
||||
dancer.update(current_time_ms, bpm)
|
||||
|
||||
def draw(self, tex: TextureWrapper):
|
||||
total_width = 1280
|
||||
num_dancers = len(self.active_dancers)
|
||||
|
||||
first_dancer = self.active_dancers[3]
|
||||
if first_dancer is None:
|
||||
return
|
||||
dancer_width = tex.textures[self.name][str(first_dancer.index) + '_loop'].width
|
||||
|
||||
available_space = total_width - (num_dancers * dancer_width)
|
||||
spacing = available_space / (num_dancers + 1)
|
||||
|
||||
for i, dancer in enumerate(self.active_dancers):
|
||||
if dancer is not None:
|
||||
dancer.draw(tex, 100 + i * 210)
|
||||
x_pos = int(spacing + i * (dancer_width + spacing))
|
||||
dancer.draw(tex, x_pos)
|
||||
|
||||
class DancerGroup0(BaseDancerGroup):
|
||||
def __init__(self, tex: TextureWrapper, index: int, bpm: float):
|
||||
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('background', f'dancer/{self.name}')
|
||||
tex.load_zip(path, f'dancer/{self.name}')
|
||||
# center (2), left (1), right (3), far left (0), far right (4)
|
||||
self.spawn_positions = [2, 1, 3, 0, 4]
|
||||
self.active_dancers = [None] * 5
|
||||
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),
|
||||
Dancer0_4(self.name, 4, bpm, tex)]
|
||||
@@ -183,13 +195,13 @@ class DancerGroup0(BaseDancerGroup):
|
||||
self.add_dancer()
|
||||
|
||||
class DancerGroupPoof1(BaseDancerGroup):
|
||||
def __init__(self, tex: TextureWrapper, index: int, bpm: float):
|
||||
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('background', f'dancer/{self.name}')
|
||||
tex.load_zip(path, f'dancer/{self.name}')
|
||||
# center (2), left (1), right (3), far left (0), far right (4)
|
||||
self.spawn_positions = [2, 1, 3, 0, 4]
|
||||
self.active_dancers = [None] * 5
|
||||
self.active_dancers = [None] * max_dancers
|
||||
dancer_classes = [DancerPoof]
|
||||
tex_set = set()
|
||||
tex_dict = tex.textures['dancer_' + str(index)]
|
||||
@@ -197,7 +209,7 @@ class DancerGroupPoof1(BaseDancerGroup):
|
||||
if key[0].isdigit():
|
||||
tex_set.add(int(key[0]))
|
||||
self.dancers = []
|
||||
for i in range(5):
|
||||
for i in range(max_dancers):
|
||||
DancerClass = random.choice(dancer_classes)
|
||||
dancer = DancerClass(self.name, i % len(tex_set), bpm, tex)
|
||||
self.dancers.append(dancer)
|
||||
@@ -206,13 +218,13 @@ class DancerGroupPoof1(BaseDancerGroup):
|
||||
self.add_dancer()
|
||||
|
||||
class DancerGroupPoof2(BaseDancerGroup):
|
||||
def __init__(self, tex: TextureWrapper, index: int, bpm: float):
|
||||
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('background', f'dancer/{self.name}')
|
||||
tex.load_zip(path, f'dancer/{self.name}')
|
||||
# center (2), left (1), right (3), far left (0), far right (4)
|
||||
self.spawn_positions = [2, 1, 3, 0, 4]
|
||||
self.active_dancers = [None] * 5
|
||||
self.active_dancers = [None] * max_dancers
|
||||
dancer_classes = [DancerPoof2]
|
||||
tex_set = set()
|
||||
tex_dict = tex.textures['dancer_' + str(index)]
|
||||
@@ -220,7 +232,7 @@ class DancerGroupPoof2(BaseDancerGroup):
|
||||
if key[0].isdigit():
|
||||
tex_set.add(int(key[0]))
|
||||
self.dancers = []
|
||||
for i in range(5):
|
||||
for i in range(max_dancers):
|
||||
DancerClass = random.choice(dancer_classes)
|
||||
dancer = DancerClass(self.name, i % len(tex_set), bpm, tex)
|
||||
self.dancers.append(dancer)
|
||||
|
||||
@@ -4,15 +4,15 @@ from libs.texture import TextureWrapper
|
||||
class DonBG:
|
||||
|
||||
@staticmethod
|
||||
def create(tex: TextureWrapper, index: int, player_num: int):
|
||||
def create(tex: TextureWrapper, index: int, player_num: int, path: str = 'background'):
|
||||
map = [DonBG1, DonBG2, DonBG3, DonBG4, DonBG5, DonBG6]
|
||||
selected_obj = map[index]
|
||||
return selected_obj(tex, index, player_num)
|
||||
return selected_obj(tex, index, player_num, path)
|
||||
|
||||
class DonBGBase:
|
||||
def __init__(self, tex: TextureWrapper, index: int, player_num: int):
|
||||
def __init__(self, tex: TextureWrapper, index: int, player_num: int, path: str):
|
||||
self.name = f'{index}_{player_num}'
|
||||
tex.load_zip('background', f'donbg/{self.name}')
|
||||
tex.load_zip(path, f'donbg/{self.name}')
|
||||
self.move = tex.get_animation(0)
|
||||
self.is_clear = False
|
||||
self.clear_fade = tex.get_animation(1)
|
||||
@@ -25,8 +25,8 @@ class DonBGBase:
|
||||
self.clear_fade.update(current_time_ms)
|
||||
|
||||
class DonBG1(DonBGBase):
|
||||
def __init__(self, tex: TextureWrapper, index: int, player_num: int):
|
||||
super().__init__(tex, index, player_num)
|
||||
def __init__(self, tex: TextureWrapper, index: int, player_num: int, path: str):
|
||||
super().__init__(tex, index, player_num, path)
|
||||
self.overlay_move = tex.get_animation(2)
|
||||
def update(self, current_time_ms: float, is_clear: bool):
|
||||
super().update(current_time_ms, is_clear)
|
||||
@@ -44,8 +44,8 @@ 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, player_num: int):
|
||||
super().__init__(tex, index, player_num)
|
||||
def __init__(self, tex: TextureWrapper, index: int, player_num: int, path: str):
|
||||
super().__init__(tex, index, player_num, path)
|
||||
self.overlay_move = tex.get_animation(3)
|
||||
def update(self, current_time_ms: float, is_clear: bool):
|
||||
super().update(current_time_ms, is_clear)
|
||||
@@ -60,8 +60,8 @@ 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, player_num: int):
|
||||
super().__init__(tex, index, player_num)
|
||||
def __init__(self, tex: TextureWrapper, index: int, player_num: int, path: str):
|
||||
super().__init__(tex, index, player_num, path)
|
||||
self.bounce_up = tex.get_animation(4)
|
||||
self.bounce_down = tex.get_animation(5)
|
||||
self.bounce_up.start()
|
||||
@@ -92,8 +92,8 @@ 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, player_num: int):
|
||||
super().__init__(tex, index, player_num)
|
||||
def __init__(self, tex: TextureWrapper, index: int, player_num: int, path: str):
|
||||
super().__init__(tex, index, player_num, path)
|
||||
self.overlay_move = tex.get_animation(2)
|
||||
def update(self, current_time_ms: float, is_clear: bool):
|
||||
super().update(current_time_ms, is_clear)
|
||||
@@ -109,8 +109,8 @@ 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, player_num: int):
|
||||
super().__init__(tex, index, player_num)
|
||||
def __init__(self, tex: TextureWrapper, index: int, player_num: int, path: str):
|
||||
super().__init__(tex, index, player_num, path)
|
||||
self.bounce_up = tex.get_animation(4)
|
||||
self.bounce_down = tex.get_animation(5)
|
||||
self.bounce_up.start()
|
||||
@@ -138,8 +138,8 @@ 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, player_num: int):
|
||||
super().__init__(tex, index, player_num)
|
||||
def __init__(self, tex: TextureWrapper, index: int, player_num: int, path: str):
|
||||
super().__init__(tex, index, player_num, path)
|
||||
self.overlay_move = tex.get_animation(2)
|
||||
def update(self, current_time_ms: float, is_clear: bool):
|
||||
super().update(current_time_ms, is_clear)
|
||||
|
||||
@@ -12,7 +12,7 @@ class Fever:
|
||||
class BaseFever:
|
||||
def __init__(self, tex: TextureWrapper, index: int, bpm: float):
|
||||
self.name = 'fever_' + str(index)
|
||||
tex.load_zip('background', f'fever/{self.name}')
|
||||
tex.load_zip('background/regular', 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)
|
||||
|
||||
|
||||
12
libs/bg_objects/footer.py
Normal file
12
libs/bg_objects/footer.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from libs.texture import TextureWrapper
|
||||
|
||||
class Footer:
|
||||
def __init__(self, tex: TextureWrapper, index: int):
|
||||
self.index = index
|
||||
if self.index == -1:
|
||||
return
|
||||
tex.load_zip('background/regular', 'footer')
|
||||
def draw(self, tex: TextureWrapper):
|
||||
if self.index == -1:
|
||||
return
|
||||
tex.draw_texture('footer', str(self.index))
|
||||
@@ -7,15 +7,15 @@ import pyray as ray
|
||||
class Renda:
|
||||
|
||||
@staticmethod
|
||||
def create(tex: TextureWrapper, index: int):
|
||||
def create(tex: TextureWrapper, index: int, path: str):
|
||||
map = [Renda0, Renda1, Renda2]
|
||||
selected_obj = map[index]
|
||||
return selected_obj(tex, index)
|
||||
return selected_obj(tex, index, path)
|
||||
|
||||
class BaseRenda:
|
||||
def __init__(self, tex: TextureWrapper, index: int):
|
||||
def __init__(self, tex: TextureWrapper, index: int, path: str):
|
||||
self.name = 'renda_' + str(index)
|
||||
tex.load_zip('background', 'renda')
|
||||
tex.load_zip(path, 'renda')
|
||||
self.hori_move = Animation.create_move(1500, total_distance=1280)
|
||||
self.hori_move.start()
|
||||
|
||||
@@ -23,8 +23,8 @@ class BaseRenda:
|
||||
self.hori_move.update(current_time_ms)
|
||||
|
||||
class Renda0(BaseRenda):
|
||||
def __init__(self, tex: TextureWrapper, index: int):
|
||||
super().__init__(tex, index)
|
||||
def __init__(self, tex: TextureWrapper, index: int, path: str):
|
||||
super().__init__(tex, index, path)
|
||||
self.vert_move = Animation.create_move(1500, total_distance=800)
|
||||
self.vert_move.start()
|
||||
self.frame = random.randint(0, 5)
|
||||
@@ -39,8 +39,8 @@ class Renda0(BaseRenda):
|
||||
tex.draw_texture('renda', self.name, frame=self.frame, x=self.hori_move.attribute+self.x, y=-self.vert_move.attribute+self.y)
|
||||
|
||||
class Renda1(BaseRenda):
|
||||
def __init__(self, tex: TextureWrapper, index: int):
|
||||
super().__init__(tex, index)
|
||||
def __init__(self, tex: TextureWrapper, index: int, path: str):
|
||||
super().__init__(tex, index, path)
|
||||
self.frame = random.randint(0, 5)
|
||||
self.y = random.randint(0, 200)
|
||||
self.rotate = Animation.create_move(800, total_distance=360)
|
||||
@@ -57,8 +57,8 @@ class Renda1(BaseRenda):
|
||||
tex.draw_texture('renda', self.name, frame=self.frame, x=self.hori_move.attribute+origin.x, y=self.y+origin.y, origin=origin, rotation=self.rotate.attribute)
|
||||
|
||||
class Renda2(BaseRenda):
|
||||
def __init__(self, tex: TextureWrapper, index: int):
|
||||
super().__init__(tex, index)
|
||||
def __init__(self, tex: TextureWrapper, index: int, path: str):
|
||||
super().__init__(tex, index, path)
|
||||
self.vert_move = Animation.create_move(1500, total_distance=800)
|
||||
self.vert_move.start()
|
||||
self.x = random.randint(0, 500)
|
||||
@@ -72,13 +72,14 @@ class Renda2(BaseRenda):
|
||||
tex.draw_texture('renda', self.name, x=self.hori_move.attribute+self.x, y=-self.vert_move.attribute+self.y)
|
||||
|
||||
class RendaController:
|
||||
def __init__(self, tex: TextureWrapper, index: int):
|
||||
def __init__(self, tex: TextureWrapper, index: int, path: str ='background'):
|
||||
self.rendas = set()
|
||||
self.tex = tex
|
||||
self.index = index
|
||||
self.path = path
|
||||
|
||||
def add_renda(self):
|
||||
self.rendas.add(Renda.create(self.tex, self.index))
|
||||
self.rendas.add(Renda.create(self.tex, self.index, self.path))
|
||||
|
||||
def update(self, current_time_ms: float):
|
||||
remove = set()
|
||||
|
||||
Reference in New Issue
Block a user