more graphics wrapper updates

This commit is contained in:
Yonokid
2025-08-11 15:03:40 -04:00
parent 60fab76c5a
commit 9b5abaa644
13 changed files with 231 additions and 320 deletions

View File

@@ -1,11 +1,10 @@
import pyray as ray
from libs.animation import Animation
from libs.utils import OutlinedText, global_data
class Transition:
def __init__(self, title: str, subtitle: str) -> None:
def __init__(self, title: str, subtitle: str, is_second: bool = False) -> None:
self.is_finished = False
self.rainbow_up = global_data.tex.get_animation(0)
self.mini_up = global_data.tex.get_animation(1)
@@ -14,7 +13,7 @@ class Transition:
self.song_info_fade_out = global_data.tex.get_animation(4)
self.title = OutlinedText(title, 40, ray.WHITE, ray.BLACK, outline_thickness=5)
self.subtitle = OutlinedText(subtitle, 30, ray.WHITE, ray.BLACK, outline_thickness=5)
self.is_second = False
self.is_second = is_second
def start(self):
self.rainbow_up.start()
@@ -67,59 +66,3 @@ class Transition:
global_data.tex.draw_texture('rainbow_transition', 'chara_center', y=-self.rainbow_up.attribute + offset - total_offset)
self.draw_song_info()
class Transition2:
def __init__(self, screen_height: int, title: str, subtitle: str) -> None:
duration = 266
self.is_finished = False
self.rainbow_up = Animation.create_move(duration, start_position=0, total_distance=screen_height + global_data.textures['scene_change_rainbow'][2].height, ease_in='cubic')
self.rainbow_up.start()
self.chara_down = None
self.title = OutlinedText(title, 40, ray.WHITE, ray.BLACK, outline_thickness=5)
self.subtitle = OutlinedText(subtitle, 30, ray.WHITE, ray.BLACK, outline_thickness=5)
self.song_info_fade = Animation.create_fade(duration/2)
self.song_info_fade.start()
def update(self, current_time_ms: float):
self.rainbow_up.update(current_time_ms)
self.song_info_fade.update(current_time_ms)
if self.rainbow_up.is_finished and self.chara_down is None:
self.chara_down = Animation.create_move(33, start_position=0, total_distance=30)
self.chara_down.start()
if self.chara_down is not None:
self.chara_down.update(current_time_ms)
self.is_finished = self.chara_down.is_finished
def draw_song_info(self):
texture = global_data.textures['scene_change_rainbow'][6]
y = 720//2 - texture.height
src = ray.Rectangle(0, 0, texture.width, texture.height)
dest = ray.Rectangle(1280//2 - (texture.width*3)//2, y, texture.width*3, texture.height*2)
ray.draw_texture_pro(texture, src, dest, ray.Vector2(0, 0), 0, ray.fade(ray.WHITE, min(0.70, self.song_info_fade.attribute)))
texture = self.title.texture
y = 720//2 - texture.height//2 - 20
src = ray.Rectangle(0, 0, texture.width, texture.height)
dest = ray.Rectangle(1280//2 - texture.width//2, y, texture.width, texture.height)
self.title.draw(src, dest, ray.Vector2(0, 0), 0, ray.fade(ray.WHITE, self.song_info_fade.attribute))
texture = self.subtitle.texture
src = ray.Rectangle(0, 0, texture.width, texture.height)
dest = ray.Rectangle(1280//2 - texture.width//2, y + 50, texture.width, texture.height)
self.subtitle.draw(src, dest, ray.Vector2(0, 0), 0, ray.fade(ray.WHITE, self.song_info_fade.attribute))
def draw(self, screen_height: int):
ray.draw_texture(global_data.textures['scene_change_rainbow'][1], 0, screen_height - int(self.rainbow_up.attribute), ray.WHITE)
texture = global_data.textures['scene_change_rainbow'][0]
src = ray.Rectangle(0, 0, texture.width, texture.height)
dest = ray.Rectangle(0, -int(self.rainbow_up.attribute), texture.width, screen_height)
ray.draw_texture_pro(texture, src, dest, ray.Vector2(0, 0), 0, ray.WHITE)
texture = global_data.textures['scene_change_rainbow'][3]
offset = 0
if self.chara_down is not None:
offset = int(self.chara_down.attribute)
ray.draw_texture(global_data.textures['scene_change_rainbow'][4], 142, 14 -int(self.rainbow_up.attribute*3) - offset, ray.WHITE)
ray.draw_texture(global_data.textures['scene_change_rainbow'][5], 958, 144 -int(self.rainbow_up.attribute*3) - offset, ray.WHITE)
ray.draw_texture(texture, 76, -int(self.rainbow_up.attribute*3) - offset, ray.WHITE)
self.draw_song_info()