add custom background implementation and A3 collab

This commit is contained in:
Anthony Samms
2025-09-12 19:31:53 -04:00
parent 08dde9e65f
commit 6b21206063
14 changed files with 240 additions and 106 deletions

View File

@@ -1,20 +1,26 @@
import random
import libs.bg_collabs
from libs.bg_objects.bg_fever import BGFever
from libs.bg_objects.bg_normal import BGNormal
from libs.bg_objects.chibi import ChibiController
from libs.bg_objects.dancer import Dancer
from libs.bg_objects.don_bg import DonBG
from libs.bg_objects.fever import Fever
from libs.bg_objects.footer import Footer
from libs.bg_objects.renda import RendaController
from libs.texture import TextureWrapper
class Background:
def __init__(self, player_num: int, bpm: float):
COLLABS = {
"A3": libs.bg_collabs.a3.A3
}
def __init__(self, player_num: int, bpm: float, scene_preset: str = ''):
self.tex_wrapper = TextureWrapper()
self.tex_wrapper.load_animations('background')
self.donbg = DonBG.create(self.tex_wrapper, random.randint(0, 5), player_num)
if scene_preset == '':
self.max_dancers = 5
self.don_bg = 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))
@@ -22,6 +28,17 @@ class Background:
self.dancer = Dancer.create(self.tex_wrapper, random.randint(0, 20), bpm)
self.renda = RendaController(self.tex_wrapper, random.randint(0, 2))
self.chibi = ChibiController(self.tex_wrapper, random.randint(0, 13), bpm)
else:
collab_bg = Background.COLLABS[scene_preset](self.tex_wrapper, bpm)
self.max_dancers = collab_bg.max_dancers
self.don_bg = collab_bg.don_bg
self.bg_normal = collab_bg.bg_normal
self.bg_fever = collab_bg.bg_fever
self.footer = collab_bg.footer
self.fever = collab_bg.fever
self.dancer = collab_bg.dancer
self.renda = collab_bg.renda
self.chibi = collab_bg.chibi
self.is_clear = False
self.is_rainbow = False
self.last_milestone = 0
@@ -37,21 +54,22 @@ class Background:
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(4, int(gauge.gauge_length / (clear_threshold / 4)))
current_milestone = min(self.max_dancers - 1, int(gauge.gauge_length / (clear_threshold / self.max_dancers - 1)))
else:
current_milestone = 5
if current_milestone > self.last_milestone and current_milestone <= 5:
current_milestone = self.max_dancers
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:
self.bg_fever.start()
if not self.is_rainbow and is_rainbow:
if not self.is_rainbow and is_rainbow and self.fever is not None:
self.fever.start()
self.is_clear = is_clear
self.is_rainbow = is_rainbow
self.donbg.update(current_time_ms, self.is_clear)
self.don_bg.update(current_time_ms, self.is_clear)
self.bg_normal.update(current_time_ms)
self.bg_fever.update(current_time_ms)
if self.fever is not None:
self.fever.update(current_time_ms, bpm)
self.dancer.update(current_time_ms, bpm)
self.renda.update(current_time_ms)
@@ -60,19 +78,13 @@ class Background:
self.bg_normal.draw(self.tex_wrapper)
if self.is_clear:
self.bg_fever.draw(self.tex_wrapper)
self.donbg.draw(self.tex_wrapper)
self.don_bg.draw(self.tex_wrapper)
self.renda.draw()
self.dancer.draw(self.tex_wrapper)
if self.footer is not None:
self.footer.draw(self.tex_wrapper)
if self.is_rainbow:
if self.is_rainbow and self.fever is not None:
self.fever.draw(self.tex_wrapper)
self.chibi.draw()
def unload(self):
self.tex_wrapper.unload_textures()
class Footer:
def __init__(self, tex: TextureWrapper, index: int):
self.index = index
tex.load_zip('background', 'footer')
def draw(self, tex: TextureWrapper):
tex.draw_texture('footer', str(self.index))

View File

@@ -0,0 +1 @@
from . import a3

85
libs/bg_collabs/a3.py Normal file
View File

@@ -0,0 +1,85 @@
import random
from libs.animation import Animation
from libs.bg_objects.bg_fever import BGFever4
from libs.bg_objects.bg_normal import BGNormal2
from libs.bg_objects.chibi import ChibiController
from libs.bg_objects.dancer import BaseDancer, BaseDancerGroup
from libs.bg_objects.don_bg import DonBGBase
from libs.bg_objects.renda import RendaController
from libs.texture import TextureWrapper
class A3:
def __init__(self, tex: TextureWrapper, bpm: float):
self.tex_wrapper = tex
path = 'background/collab/A3'
self.max_dancers = 4
self.don_bg = DonBG(self.tex_wrapper, 0, 1, path)
self.bg_normal = BGNormal(self.tex_wrapper, 0, path)
self.bg_fever = BGFever(self.tex_wrapper, 0, path)
self.footer = None
self.fever = None
self.dancer = DancerGroup(self.tex_wrapper, 0, bpm, self.max_dancers, path)
self.renda = RendaController(self.tex_wrapper, 0, path)
self.chibi = ChibiController(self.tex_wrapper, 0, bpm, path)
for _ in range(3):
self.dancer.add_dancer()
class BGFever(BGFever4):
def __init__(self, tex: TextureWrapper, index: int, path: str):
super().__init__(tex, index, path)
self.vertical_move = Animation.create_move(tex.animations[15].duration, total_distance=328)
self.vertical_move.start()
self.vertical_move.loop = True
def draw(self, tex: TextureWrapper):
tex.draw_texture(self.name, 'overlay')
for i in range(10):
for j in range(2):
tex.draw_texture(self.name, 'petals', x=(i * 328)-self.horizontal_move.attribute, y=(j * 328) + self.vertical_move.attribute)
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}')
# center (2), left (1), right (3), far left (0), far right (4)
self.spawn_positions = [2, 1, 3, 0, 4]
self.active_dancers = [None] * max_dancers
dancer_classes = [Dancer]
tex_set = set()
tex_dict = tex.textures['dancer_' + str(index)]
for key in tex_dict.keys():
if key[0].isdigit():
tex_set.add(int(key[0]))
self.dancers = []
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)
random.shuffle(self.dancers)
self.add_dancer()
class Dancer(BaseDancer):
def draw(self, tex: TextureWrapper, x: int):
super().draw(tex, x)
tex.draw_texture(self.name, 'shadow', x=x, fade=0.50)
class BGNormal(BGNormal2):
def draw(self, tex: TextureWrapper):
super().draw(tex)
tex.draw_texture(self.name, 'curtain')
class DonBG(DonBGBase):
def __init__(self, tex: TextureWrapper, index: int, player_num: int, path: str):
super().__init__(tex, index, player_num, path)
self.move = Animation.create_move(10000, total_distance=-1280)
self.move.start()
self.move.loop = True
def draw(self, tex: TextureWrapper):
self._draw_textures(tex, 1.0)
if self.is_clear:
self._draw_textures(tex, self.clear_fade.attribute)
def _draw_textures(self, tex: TextureWrapper, fade: float):
for i in range(2):
tex.draw_texture(self.name, 'background', frame=self.is_clear, fade=fade, x=(i*1280)+self.move.attribute)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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))

View File

@@ -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)

View File

@@ -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)

View File

@@ -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
View 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))

View File

@@ -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()

View File

@@ -130,6 +130,7 @@ class TJAMetadata:
bpm: float = 120.0
bgmovie: Path = Path()
movieoffset: float = 0.0
scene_preset: str = ''
course_data: dict[int, CourseData] = field(default_factory=dict)
@dataclass
@@ -224,6 +225,8 @@ class TJAParser:
self.metadata.bgmovie = self.file_path.parent / item.split(':')[1].strip()
elif item.startswith('MOVIEOFFSET'):
self.metadata.movieoffset = float(item.split(':')[1])
elif item.startswith('SCENEPRESET'):
self.metadata.scene_preset = item.split(':')[1]
elif item.startswith('COURSE'):
course = str(item.split(':')[1]).lower().strip()

View File

@@ -97,9 +97,11 @@ class GameScreen:
if self.tja is not None:
subtitle = self.tja.metadata.subtitle.get(global_data.config['general']['language'].lower(), '')
self.bpm = self.tja.metadata.bpm
scene_preset = self.tja.metadata.scene_preset
else:
subtitle = ''
self.background = Background(global_data.player_num, self.bpm)
scene_preset = ''
self.background = Background(global_data.player_num, self.bpm, scene_preset=scene_preset)
self.transition = Transition(session_data.song_title, subtitle, is_second=True)
self.transition.start()
@@ -1298,6 +1300,7 @@ class SongInfo:
dest = ray.Rectangle(text_x, text_y, self.song_title.texture.width, self.song_title.texture.height)
self.song_title.draw(self.song_title.default_src, dest, ray.Vector2(0, 0), 0, ray.fade(ray.WHITE, 1 - self.fade.attribute))
if self.genre < 9:
tex.draw_texture('song_info', 'genre', fade=1 - self.fade.attribute, frame=self.genre)
class ResultTransition:

View File

@@ -101,7 +101,7 @@ class SongSelectScreen:
if self.navigator.items != []:
global_data.selected_song = self.navigator.get_current_item().path
session_data.selected_difficulty = self.selected_difficulty
session_data.genre_index = self.navigator.get_current_item().box.texture_index
session_data.genre_index = self.navigator.get_current_item().box.name_texture_index
self.reset_demo_music()
self.navigator.reset_items()
audio.unload_all_sounds()