mirror of
https://github.com/Yonokid/PyTaiko.git
synced 2026-02-04 11:40:13 +01:00
Add doc strings
This commit is contained in:
@@ -7,18 +7,19 @@ import pyray as ray
|
||||
class Chibi:
|
||||
|
||||
@staticmethod
|
||||
def create(index: int, bpm: float, bad: bool, tex: TextureWrapper):
|
||||
def create(index: int, bpm: float, bad: bool, tex: TextureWrapper, is_2p: bool):
|
||||
if bad:
|
||||
return ChibiBad(index, bpm, tex)
|
||||
return ChibiBad(index, bpm, tex, is_2p)
|
||||
map = [Chibi0, BaseChibi, Chibi2, BaseChibi, Chibi4, Chibi5, BaseChibi,
|
||||
BaseChibi, Chibi8, BaseChibi, BaseChibi, BaseChibi, BaseChibi, Chibi13]
|
||||
selected_obj = map[index]
|
||||
return selected_obj(index, bpm, tex)
|
||||
return selected_obj(index, bpm, tex, is_2p)
|
||||
|
||||
class BaseChibi:
|
||||
def __init__(self, index: int, bpm: float, tex: TextureWrapper):
|
||||
def __init__(self, index: int, bpm: float, tex: TextureWrapper, is_2p: bool):
|
||||
self.name = 'chibi_' + str(index)
|
||||
self.bpm = bpm
|
||||
self.is_2p = is_2p
|
||||
self.hori_move = Animation.create_move(60000 / self.bpm * 5, total_distance=1280)
|
||||
self.hori_move.start()
|
||||
self.vert_move = Animation.create_move(60000 / self.bpm / 2, total_distance=50, reverse_delay=0)
|
||||
@@ -42,10 +43,11 @@ class BaseChibi:
|
||||
self.texture_change.restart()
|
||||
|
||||
def draw(self, tex: TextureWrapper):
|
||||
tex.draw_texture(self.name, str(self.index), frame=self.texture_change.attribute, x=self.hori_move.attribute, y=-self.vert_move.attribute)
|
||||
tex.draw_texture(self.name, str(self.index), frame=self.texture_change.attribute, x=self.hori_move.attribute, y=-self.vert_move.attribute+(self.is_2p*535))
|
||||
|
||||
class ChibiBad(BaseChibi):
|
||||
def __init__(self, index: int, bpm: float, tex: TextureWrapper):
|
||||
def __init__(self, index: int, bpm: float, tex: TextureWrapper, is_2p: bool):
|
||||
self.is_2p = is_2p
|
||||
self.bpm = bpm
|
||||
self.index = random.randint(0, 2)
|
||||
self.keyframes = [3, 4]
|
||||
@@ -72,17 +74,17 @@ class ChibiBad(BaseChibi):
|
||||
|
||||
def draw(self, tex: TextureWrapper):
|
||||
if not self.s_texture_change.is_finished:
|
||||
tex.draw_texture('chibi_bad', '0', frame=self.s_texture_change.attribute, x=self.hori_move.attribute, y=self.vert_move.attribute, fade=self.fade_in.attribute)
|
||||
tex.draw_texture('chibi_bad', '0', frame=self.s_texture_change.attribute, x=self.hori_move.attribute, y=self.vert_move.attribute+(self.is_2p*535), fade=self.fade_in.attribute)
|
||||
else:
|
||||
tex.draw_texture('chibi_bad', '0', frame=self.texture_change.attribute, x=self.hori_move.attribute, y=self.vert_move.attribute)
|
||||
tex.draw_texture('chibi_bad', '0', frame=self.texture_change.attribute, x=self.hori_move.attribute, y=self.vert_move.attribute+(self.is_2p*535))
|
||||
|
||||
class Chibi0(BaseChibi):
|
||||
def draw(self, tex: TextureWrapper):
|
||||
tex.draw_texture(self.name, str(self.index), frame=self.texture_change.attribute, x=self.hori_move.attribute, y=self.vert_move.attribute)
|
||||
tex.draw_texture(self.name, str(self.index), frame=self.texture_change.attribute, x=self.hori_move.attribute, y=self.vert_move.attribute+(self.is_2p*535))
|
||||
|
||||
class Chibi2(BaseChibi):
|
||||
def __init__(self, index: int, bpm: float, tex: TextureWrapper):
|
||||
super().__init__(index, bpm, tex)
|
||||
def __init__(self, index: int, bpm: float, tex: TextureWrapper, is_2p: bool):
|
||||
super().__init__(index, bpm, tex, is_2p)
|
||||
self.rotate = Animation.create_move(60000 / self.bpm / 2, total_distance=360, reverse_delay=0)
|
||||
self.rotate.start()
|
||||
|
||||
@@ -94,23 +96,23 @@ class Chibi2(BaseChibi):
|
||||
|
||||
def draw(self, tex: TextureWrapper):
|
||||
origin = ray.Vector2(64, 64)
|
||||
tex.draw_texture(self.name, str(self.index), x=self.hori_move.attribute+origin.x, y=origin.y, origin=origin, rotation=self.rotate.attribute)
|
||||
tex.draw_texture(self.name, str(self.index), x=self.hori_move.attribute+origin.x, y=origin.y+(self.is_2p*535), origin=origin, rotation=self.rotate.attribute)
|
||||
|
||||
class Chibi4(BaseChibi):
|
||||
def draw(self, tex: TextureWrapper):
|
||||
tex.draw_texture(self.name, str(self.index), frame=self.texture_change.attribute, x=self.hori_move.attribute)
|
||||
tex.draw_texture(self.name, str(self.index), frame=self.texture_change.attribute, x=self.hori_move.attribute, y=(self.is_2p*535))
|
||||
|
||||
class Chibi5(BaseChibi):
|
||||
def draw(self, tex: TextureWrapper):
|
||||
tex.draw_texture(self.name, str(self.index), frame=self.texture_change.attribute, x=self.hori_move.attribute)
|
||||
tex.draw_texture(self.name, str(self.index), frame=self.texture_change.attribute, x=self.hori_move.attribute, y=(self.is_2p*535))
|
||||
|
||||
class Chibi8(BaseChibi):
|
||||
def draw(self, tex: TextureWrapper):
|
||||
tex.draw_texture(self.name, str(self.index), frame=self.texture_change.attribute, x=self.hori_move.attribute)
|
||||
tex.draw_texture(self.name, str(self.index), frame=self.texture_change.attribute, x=self.hori_move.attribute, y=(self.is_2p*535))
|
||||
|
||||
class Chibi13(BaseChibi):
|
||||
def __init__(self, index: int, bpm: float, tex: TextureWrapper):
|
||||
super().__init__(index, bpm, tex)
|
||||
def __init__(self, index: int, bpm: float, tex: TextureWrapper, is_2p: bool):
|
||||
super().__init__(index, bpm, tex, is_2p)
|
||||
duration = (60000 / self.bpm)
|
||||
self.scale = Animation.create_fade(duration, initial_opacity=1.0, final_opacity=0.75, delay=duration, reverse_delay=duration)
|
||||
self.scale.start()
|
||||
@@ -129,9 +131,9 @@ class Chibi13(BaseChibi):
|
||||
def draw(self, tex: TextureWrapper):
|
||||
tex.draw_texture(self.name, 'tail', frame=self.frame, x=self.hori_move.attribute, y=-self.vert_move.attribute)
|
||||
if self.scale.attribute == 0.75:
|
||||
tex.draw_texture(self.name, str(self.index), frame=self.frame, x=self.hori_move.attribute, y=-self.vert_move.attribute)
|
||||
tex.draw_texture(self.name, str(self.index), frame=self.frame, x=self.hori_move.attribute, y=-self.vert_move.attribute+(self.is_2p*535))
|
||||
else:
|
||||
tex.draw_texture(self.name, str(self.index), scale=self.scale.attribute, center=True, frame=self.frame, x=self.hori_move.attribute, y=-self.vert_move.attribute)
|
||||
tex.draw_texture(self.name, str(self.index), scale=self.scale.attribute, center=True, frame=self.frame, x=self.hori_move.attribute, y=-self.vert_move.attribute+(self.is_2p*535))
|
||||
|
||||
|
||||
class ChibiController:
|
||||
@@ -144,8 +146,8 @@ class ChibiController:
|
||||
tex.load_zip(path, f'chibi/{self.name}')
|
||||
tex.load_zip('background', 'chibi/chibi_bad')
|
||||
|
||||
def add_chibi(self, bad=False):
|
||||
self.chibis.append(Chibi.create(self.index, self.bpm, bad, self.tex))
|
||||
def add_chibi(self, player_num: int, bad=False):
|
||||
self.chibis.append(Chibi.create(self.index, self.bpm, bad, self.tex, player_num == 2))
|
||||
|
||||
def update(self, current_time_ms: float, bpm: float):
|
||||
self.bpm = bpm
|
||||
|
||||
@@ -31,17 +31,17 @@ class DonBG1(DonBGBase):
|
||||
def update(self, current_time_ms: float, is_clear: bool):
|
||||
super().update(current_time_ms, is_clear)
|
||||
self.overlay_move.update(current_time_ms)
|
||||
def draw(self, tex: TextureWrapper):
|
||||
self._draw_textures(tex, 1.0)
|
||||
def draw(self, tex: TextureWrapper, y: float=0):
|
||||
self._draw_textures(tex, 1.0, y)
|
||||
if self.is_clear:
|
||||
self._draw_textures(tex, self.clear_fade.attribute)
|
||||
def _draw_textures(self, tex: TextureWrapper, fade: float):
|
||||
self._draw_textures(tex, self.clear_fade.attribute, y)
|
||||
def _draw_textures(self, tex: TextureWrapper, fade: float, y: float):
|
||||
for i in range(5):
|
||||
tex.draw_texture(self.name, 'background', frame=self.is_clear, fade=fade, x=(i*328)+self.move.attribute)
|
||||
tex.draw_texture(self.name, 'background', frame=self.is_clear, fade=fade, x=(i*328)+self.move.attribute, y=y)
|
||||
for i in range(6):
|
||||
tex.draw_texture(self.name, 'overlay', frame=self.is_clear, fade=fade, x=(i*347)+self.move.attribute*(347/328), y=self.overlay_move.attribute)
|
||||
tex.draw_texture(self.name, 'overlay', frame=self.is_clear, fade=fade, x=(i*347)+self.move.attribute*(347/328), y=self.overlay_move.attribute+y)
|
||||
for i in range(30):
|
||||
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)
|
||||
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+y)
|
||||
|
||||
class DonBG2(DonBGBase):
|
||||
def __init__(self, tex: TextureWrapper, index: int, player_num: int, path: str):
|
||||
@@ -50,14 +50,14 @@ class DonBG2(DonBGBase):
|
||||
def update(self, current_time_ms: float, is_clear: bool):
|
||||
super().update(current_time_ms, is_clear)
|
||||
self.overlay_move.update(current_time_ms)
|
||||
def draw(self, tex: TextureWrapper):
|
||||
self._draw_textures(tex, 1.0)
|
||||
def draw(self, tex: TextureWrapper, y: float = 0):
|
||||
self._draw_textures(tex, 1.0, y)
|
||||
if self.is_clear:
|
||||
self._draw_textures(tex, self.clear_fade.attribute)
|
||||
def _draw_textures(self, tex: TextureWrapper, fade: float):
|
||||
self._draw_textures(tex, self.clear_fade.attribute, y)
|
||||
def _draw_textures(self, tex: TextureWrapper, fade: float, y: float):
|
||||
for i in range(5):
|
||||
tex.draw_texture(self.name, 'background', frame=self.is_clear, fade=fade, x=(i*328)+self.move.attribute)
|
||||
tex.draw_texture(self.name, 'overlay', frame=self.is_clear, fade=fade, x=(i*328)+self.move.attribute, y=self.overlay_move.attribute)
|
||||
tex.draw_texture(self.name, 'background', frame=self.is_clear, fade=fade, x=(i*328)+self.move.attribute, y=y)
|
||||
tex.draw_texture(self.name, 'overlay', frame=self.is_clear, fade=fade, x=(i*328)+self.move.attribute, y=self.overlay_move.attribute+y)
|
||||
|
||||
class DonBG3(DonBGBase):
|
||||
def __init__(self, tex: TextureWrapper, index: int, player_num: int, path: str):
|
||||
@@ -79,17 +79,17 @@ class DonBG3(DonBGBase):
|
||||
self.overlay_move.update(current_time_ms)
|
||||
self.overlay_move_2.update(current_time_ms)
|
||||
|
||||
def draw(self, tex: TextureWrapper):
|
||||
self._draw_textures(tex, 1.0)
|
||||
def draw(self, tex: TextureWrapper, y: float = 0):
|
||||
self._draw_textures(tex, 1.0, y)
|
||||
if self.is_clear:
|
||||
self._draw_textures(tex, self.clear_fade.attribute)
|
||||
self._draw_textures(tex, self.clear_fade.attribute, y)
|
||||
|
||||
def _draw_textures(self, tex: TextureWrapper, fade: float):
|
||||
def _draw_textures(self, tex: TextureWrapper, fade: float, y: float):
|
||||
for i in range(10):
|
||||
tex.draw_texture(self.name, 'background', frame=self.is_clear, fade=fade, x=(i*164)+self.move.attribute)
|
||||
y = self.bounce_up.attribute - self.bounce_down.attribute + self.overlay_move.attribute + self.overlay_move_2.attribute
|
||||
tex.draw_texture(self.name, 'background', frame=self.is_clear, fade=fade, x=(i*164)+self.move.attribute, y=y)
|
||||
y_pos = self.bounce_up.attribute - self.bounce_down.attribute + self.overlay_move.attribute + self.overlay_move_2.attribute
|
||||
for i in range(6):
|
||||
tex.draw_texture(self.name, 'overlay', frame=self.is_clear, fade=fade, x=(i*328)+(self.move.attribute*2), y=y)
|
||||
tex.draw_texture(self.name, 'overlay', frame=self.is_clear, fade=fade, x=(i*328)+(self.move.attribute*2), y=y_pos+y)
|
||||
|
||||
class DonBG4(DonBGBase):
|
||||
def __init__(self, tex: TextureWrapper, index: int, player_num: int, path: str):
|
||||
@@ -98,15 +98,15 @@ class DonBG4(DonBGBase):
|
||||
def update(self, current_time_ms: float, is_clear: bool):
|
||||
super().update(current_time_ms, is_clear)
|
||||
self.overlay_move.update(current_time_ms)
|
||||
def draw(self, tex: TextureWrapper):
|
||||
self._draw_textures(tex, 1.0)
|
||||
def draw(self, tex: TextureWrapper, y: float = 0):
|
||||
self._draw_textures(tex, 1.0, y)
|
||||
if self.is_clear:
|
||||
self._draw_textures(tex, self.clear_fade.attribute)
|
||||
self._draw_textures(tex, self.clear_fade.attribute, y)
|
||||
|
||||
def _draw_textures(self, tex: TextureWrapper, fade: float):
|
||||
def _draw_textures(self, tex: TextureWrapper, fade: float, y: float):
|
||||
for i in range(5):
|
||||
tex.draw_texture(self.name, 'background', frame=self.is_clear, fade=fade, x=(i*328)+self.move.attribute)
|
||||
tex.draw_texture(self.name, 'overlay', frame=self.is_clear, fade=fade, x=(i*328)+self.move.attribute, y=self.overlay_move.attribute)
|
||||
tex.draw_texture(self.name, 'background', frame=self.is_clear, fade=fade, x=(i*328)+self.move.attribute, y=y)
|
||||
tex.draw_texture(self.name, 'overlay', frame=self.is_clear, fade=fade, x=(i*328)+self.move.attribute, y=self.overlay_move.attribute+y)
|
||||
|
||||
class DonBG5(DonBGBase):
|
||||
def __init__(self, tex: TextureWrapper, index: int, player_num: int, path: str):
|
||||
@@ -126,16 +126,16 @@ class DonBG5(DonBGBase):
|
||||
self.bounce_down.restart()
|
||||
self.adjust.update(current_time_ms)
|
||||
|
||||
def draw(self, tex: TextureWrapper):
|
||||
self._draw_textures(tex, 1.0)
|
||||
def draw(self, tex: TextureWrapper, y: float = 0):
|
||||
self._draw_textures(tex, 1.0, y)
|
||||
if self.is_clear:
|
||||
self._draw_textures(tex, self.clear_fade.attribute)
|
||||
self._draw_textures(tex, self.clear_fade.attribute, y)
|
||||
|
||||
def _draw_textures(self, tex: TextureWrapper, fade: float):
|
||||
def _draw_textures(self, tex: TextureWrapper, fade: float, y: float):
|
||||
for i in range(5):
|
||||
tex.draw_texture(self.name, 'background', frame=self.is_clear, fade=fade, x=(i*328)+self.move.attribute)
|
||||
tex.draw_texture(self.name, 'background', frame=self.is_clear, fade=fade, x=(i*328)+self.move.attribute, y=y)
|
||||
for i in range(6):
|
||||
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)
|
||||
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 + y)
|
||||
|
||||
class DonBG6(DonBGBase):
|
||||
def __init__(self, tex: TextureWrapper, index: int, player_num: int, path: str):
|
||||
@@ -144,15 +144,15 @@ class DonBG6(DonBGBase):
|
||||
def update(self, current_time_ms: float, is_clear: bool):
|
||||
super().update(current_time_ms, is_clear)
|
||||
self.overlay_move.update(current_time_ms)
|
||||
def draw(self, tex: TextureWrapper):
|
||||
self._draw_textures(tex, 1.0)
|
||||
def draw(self, tex: TextureWrapper, y: float = 0):
|
||||
self._draw_textures(tex, 1.0, y)
|
||||
if self.is_clear:
|
||||
self._draw_textures(tex, self.clear_fade.attribute)
|
||||
self._draw_textures(tex, self.clear_fade.attribute, y)
|
||||
|
||||
def _draw_textures(self, tex: TextureWrapper, fade: float):
|
||||
def _draw_textures(self, tex: TextureWrapper, fade: float, y: float):
|
||||
for i in range(5):
|
||||
tex.draw_texture(self.name, 'background', frame=self.is_clear, fade=fade, x=(i*328)+self.move.attribute)
|
||||
tex.draw_texture(self.name, 'background', frame=self.is_clear, fade=fade, x=(i*328)+self.move.attribute, y=y)
|
||||
for i in range(0, 6, 2):
|
||||
tex.draw_texture(self.name, 'overlay_1', frame=self.is_clear, fade=fade, x=(i*264) + self.move.attribute*3, y=-self.move.attribute*0.85)
|
||||
tex.draw_texture(self.name, 'overlay_1', frame=self.is_clear, fade=fade, x=(i*264) + self.move.attribute*3, y=-self.move.attribute*0.85+y)
|
||||
for i in range(5):
|
||||
tex.draw_texture(self.name, 'overlay_2', frame=self.is_clear, fade=fade, x=(i*328)+self.move.attribute, y=self.overlay_move.attribute)
|
||||
tex.draw_texture(self.name, 'overlay_2', frame=self.is_clear, fade=fade, x=(i*328)+self.move.attribute, y=self.overlay_move.attribute+y)
|
||||
|
||||
Reference in New Issue
Block a user