mirror of
https://github.com/Yonokid/PyTaiko.git
synced 2026-02-04 11:40:13 +01:00
Add entry screen
This commit is contained in:
@@ -18,7 +18,7 @@ right_kat = ['K']
|
|||||||
|
|
||||||
[audio]
|
[audio]
|
||||||
device_type = "Windows WASAPI"
|
device_type = "Windows WASAPI"
|
||||||
buffer_size = 22
|
buffer_size = 64
|
||||||
sample_rate = -1
|
sample_rate = -1
|
||||||
exclusive = false
|
exclusive = false
|
||||||
|
|
||||||
|
|||||||
@@ -116,11 +116,12 @@ class MoveAnimation(BaseAnimation):
|
|||||||
self.attribute = self.start_position + (self.total_distance * progress)
|
self.attribute = self.start_position + (self.total_distance * progress)
|
||||||
|
|
||||||
class TextureChangeAnimation(BaseAnimation):
|
class TextureChangeAnimation(BaseAnimation):
|
||||||
def __init__(self, duration: float, textures: list[tuple[float, float, int]]):
|
def __init__(self, duration: float, textures: list[tuple[float, float, int]], delay: float):
|
||||||
super().__init__(duration)
|
super().__init__(duration)
|
||||||
self.textures = textures
|
self.textures = textures
|
||||||
|
self.delay = delay
|
||||||
def update(self, current_time_ms: float):
|
def update(self, current_time_ms: float):
|
||||||
elapsed_time = current_time_ms - self.start_ms
|
elapsed_time = current_time_ms - self.start_ms - self.delay
|
||||||
if elapsed_time <= self.duration:
|
if elapsed_time <= self.duration:
|
||||||
for start, end, index in self.textures:
|
for start, end, index in self.textures:
|
||||||
if start < elapsed_time <= end:
|
if start < elapsed_time <= end:
|
||||||
@@ -223,6 +224,7 @@ class Animation:
|
|||||||
Args:
|
Args:
|
||||||
duration: Length of the change in milliseconds
|
duration: Length of the change in milliseconds
|
||||||
textures: Passed in as a tuple of the starting millisecond, ending millisecond, and texture index
|
textures: Passed in as a tuple of the starting millisecond, ending millisecond, and texture index
|
||||||
|
delay: Time to wait before starting the change
|
||||||
"""
|
"""
|
||||||
return TextureChangeAnimation(duration, **kwargs)
|
return TextureChangeAnimation(duration, **kwargs)
|
||||||
|
|
||||||
|
|||||||
@@ -136,3 +136,5 @@ class VideoPlayer:
|
|||||||
|
|
||||||
if audio.is_music_stream_playing(self.audio):
|
if audio.is_music_stream_playing(self.audio):
|
||||||
audio.stop_music_stream(self.audio)
|
audio.stop_music_stream(self.audio)
|
||||||
|
|
||||||
|
self.video.close()
|
||||||
|
|||||||
263
scenes/entry.py
263
scenes/entry.py
@@ -2,32 +2,277 @@ from pathlib import Path
|
|||||||
|
|
||||||
import pyray as ray
|
import pyray as ray
|
||||||
|
|
||||||
from libs.utils import is_l_don_pressed, is_r_don_pressed, load_texture_from_zip
|
from libs.animation import Animation
|
||||||
|
from libs.audio import audio
|
||||||
|
from libs.utils import (
|
||||||
|
OutlinedText,
|
||||||
|
draw_scaled_texture,
|
||||||
|
get_current_ms,
|
||||||
|
is_l_don_pressed,
|
||||||
|
is_l_kat_pressed,
|
||||||
|
is_r_don_pressed,
|
||||||
|
is_r_kat_pressed,
|
||||||
|
load_all_textures_from_zip,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class State:
|
||||||
|
SELECT_SIDE = 0
|
||||||
|
SELECT_MODE = 1
|
||||||
|
|
||||||
class EntryScreen:
|
class EntryScreen:
|
||||||
def __init__(self, width: int, height: int):
|
def __init__(self, width: int, height: int):
|
||||||
self.width = width
|
self.width = width
|
||||||
self.height = height
|
self.height = height
|
||||||
|
|
||||||
self.texture_footer = load_texture_from_zip(Path('Graphics/lumendata/entry.zip'), 'entry_img00375.png')
|
|
||||||
|
|
||||||
self.screen_init = False
|
self.screen_init = False
|
||||||
|
self.box_titles: list[tuple[OutlinedText, OutlinedText]] = [(OutlinedText('演奏ゲーム', 50, ray.Color(255, 255, 255, 255), ray.Color(109, 68, 24, 255), outline_thickness=5, vertical=True),
|
||||||
|
OutlinedText('演奏ゲーム', 50, ray.Color(255, 255, 255, 255), ray.Color(0, 0, 0, 255), outline_thickness=5, vertical=True)),
|
||||||
|
(OutlinedText('ゲーム設定', 50, ray.Color(255, 255, 255, 255), ray.Color(109, 68, 24, 255), outline_thickness=5, vertical=True),
|
||||||
|
OutlinedText('ゲーム設定', 50, ray.Color(255, 255, 255, 255), ray.Color(0, 0, 0, 255), outline_thickness=5, vertical=True))]
|
||||||
|
|
||||||
|
def load_textures(self):
|
||||||
|
self.textures = load_all_textures_from_zip(Path('Graphics/lumendata/entry.zip'))
|
||||||
|
|
||||||
|
def unload_textures(self):
|
||||||
|
for group in self.textures:
|
||||||
|
for texture in self.textures[group]:
|
||||||
|
ray.unload_texture(texture)
|
||||||
|
|
||||||
|
def load_sounds(self):
|
||||||
|
sounds_dir = Path("Sounds")
|
||||||
|
self.sound_don = audio.load_sound(sounds_dir / "inst_00_don.wav")
|
||||||
|
self.sound_kat = audio.load_sound(sounds_dir / "inst_00_katsu.wav")
|
||||||
|
|
||||||
def on_screen_start(self):
|
def on_screen_start(self):
|
||||||
if not self.screen_init:
|
if not self.screen_init:
|
||||||
|
self.load_textures()
|
||||||
|
self.load_sounds()
|
||||||
|
self.side = 1
|
||||||
|
self.selected_box = 0
|
||||||
|
self.num_boxes = 2
|
||||||
|
self.state = State.SELECT_SIDE
|
||||||
self.screen_init = True
|
self.screen_init = True
|
||||||
|
self.drum_move_1 = None
|
||||||
|
self.drum_move_2 = None
|
||||||
|
self.drum_move_3 = None
|
||||||
|
self.cloud_resize = None
|
||||||
|
self.cloud_texture_change = None
|
||||||
|
self.cloud_fade = None
|
||||||
|
self.cloud_resize_loop = Animation.create_texture_resize(200, initial_size=1.0, final_size=1.1, reverse_delay=200)
|
||||||
|
|
||||||
def on_screen_end(self, next_screen: str):
|
def on_screen_end(self, next_screen: str):
|
||||||
self.screen_init = False
|
self.screen_init = False
|
||||||
|
self.unload_textures()
|
||||||
return next_screen
|
return next_screen
|
||||||
|
|
||||||
|
def handle_input(self):
|
||||||
|
if self.state == State.SELECT_SIDE:
|
||||||
|
if is_l_don_pressed() or is_r_don_pressed():
|
||||||
|
if self.side == 1:
|
||||||
|
return self.on_screen_end("TITLE")
|
||||||
|
self.drum_move_1 = Animation.create_move(350, total_distance=-295, ease_out='quadratic')
|
||||||
|
self.drum_move_2 = Animation.create_move(200, total_distance=50, delay=self.drum_move_1.duration, ease_in='quadratic')
|
||||||
|
self.drum_move_3 = Animation.create_move(350, total_distance=-170, delay=self.drum_move_1.duration+self.drum_move_2.duration, ease_out='quadratic')
|
||||||
|
self.cloud_resize = Animation.create_texture_resize(350, initial_size=0.75, final_size=1.0)
|
||||||
|
self.cloud_resize_loop = Animation.create_texture_resize(200, initial_size=1.0, final_size=1.2, reverse_delay=200, delay=self.cloud_resize.duration)
|
||||||
|
textures = ((0, 83.35, 45), (83.35, 166.7, 48), (166.7, 250, 49), (250, 333, 50))
|
||||||
|
self.cloud_texture_change = Animation.create_texture_change(333, textures=textures, delay=self.drum_move_1.duration+self.drum_move_2.duration+self.drum_move_3.duration)
|
||||||
|
self.cloud_fade = Animation.create_fade(83.35, delay=self.drum_move_1.duration+self.drum_move_2.duration+self.drum_move_3.duration+self.cloud_texture_change.duration)
|
||||||
|
self.state = State.SELECT_MODE
|
||||||
|
audio.play_sound(self.sound_don)
|
||||||
|
if is_l_kat_pressed():
|
||||||
|
audio.play_sound(self.sound_kat)
|
||||||
|
self.side = max(0, self.side - 1)
|
||||||
|
if is_r_kat_pressed():
|
||||||
|
audio.play_sound(self.sound_kat)
|
||||||
|
self.side = min(2, self.side + 1)
|
||||||
|
elif self.state == State.SELECT_MODE:
|
||||||
|
if is_l_don_pressed() or is_r_don_pressed():
|
||||||
|
audio.play_sound(self.sound_don)
|
||||||
|
if self.selected_box == 0:
|
||||||
|
return self.on_screen_end("SONG_SELECT")
|
||||||
|
elif self.selected_box == 1:
|
||||||
|
return self.on_screen_end("SETTINGS")
|
||||||
|
if is_l_kat_pressed():
|
||||||
|
audio.play_sound(self.sound_kat)
|
||||||
|
self.selected_box = max(0, self.selected_box - 1)
|
||||||
|
if is_r_kat_pressed():
|
||||||
|
audio.play_sound(self.sound_kat)
|
||||||
|
self.selected_box = min(self.num_boxes, self.selected_box + 1)
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
self.on_screen_start()
|
self.on_screen_start()
|
||||||
if is_l_don_pressed() or is_r_don_pressed():
|
if self.drum_move_1 is not None:
|
||||||
return self.on_screen_end("SONG_SELECT")
|
self.drum_move_1.update(get_current_ms())
|
||||||
if ray.is_key_pressed(ray.KeyboardKey.KEY_F1):
|
if self.drum_move_2 is not None:
|
||||||
return self.on_screen_end("SETTINGS")
|
self.drum_move_2.update(get_current_ms())
|
||||||
|
if self.drum_move_3 is not None:
|
||||||
|
self.drum_move_3.update(get_current_ms())
|
||||||
|
if self.cloud_resize is not None:
|
||||||
|
self.cloud_resize.update(get_current_ms())
|
||||||
|
if self.cloud_texture_change is not None:
|
||||||
|
self.cloud_texture_change.update(get_current_ms())
|
||||||
|
if self.cloud_fade is not None:
|
||||||
|
self.cloud_fade.update(get_current_ms())
|
||||||
|
self.cloud_resize_loop.update(get_current_ms())
|
||||||
|
if self.cloud_resize_loop.is_finished:
|
||||||
|
self.cloud_resize_loop = Animation.create_texture_resize(200, initial_size=1.0, final_size=1.1, reverse_delay=200)
|
||||||
|
return self.handle_input()
|
||||||
|
|
||||||
|
def draw_background(self):
|
||||||
|
bg_texture = self.textures['entry'][368]
|
||||||
|
src = ray.Rectangle(0, 0, bg_texture.width, bg_texture.height)
|
||||||
|
dest = ray.Rectangle(0, 0, self.width, bg_texture.height)
|
||||||
|
ray.draw_texture_pro(bg_texture, src, dest, ray.Vector2(0, 0), 0, ray.WHITE)
|
||||||
|
|
||||||
|
ray.draw_texture(self.textures['entry'][369], (self.width // 2) - (self.textures['entry'][369].width // 2), (self.height // 2) - self.textures['entry'][369].height, ray.WHITE)
|
||||||
|
ray.draw_texture(self.textures['entry'][370], 0, (self.height // 2) - (self.textures['entry'][370].height // 2), ray.WHITE)
|
||||||
|
ray.draw_texture(self.textures['entry'][371], (self.width // 2) - (self.textures['entry'][371].width // 2), (self.height // 2) - (self.textures['entry'][371].height // 2) + 10, ray.WHITE)
|
||||||
|
ray.draw_texture(self.textures['entry'][372], 0, 0, ray.WHITE)
|
||||||
|
ray.draw_texture(self.textures['entry'][373], self.width - self.textures['entry'][373].width, 0, ray.WHITE)
|
||||||
|
draw_scaled_texture(self.textures['entry'][374], -7, -15, 2.0, ray.fade(ray.WHITE, 0.50))
|
||||||
|
|
||||||
|
def draw_footer(self):
|
||||||
|
ray.draw_texture(self.textures['entry'][375], 1, self.height - self.textures['entry'][375].height + 7, ray.WHITE)
|
||||||
|
if self.state == State.SELECT_SIDE or self.side != 0:
|
||||||
|
ray.draw_texture(self.textures['entry'][376], 1, self.height - self.textures['entry'][376].height + 1, ray.WHITE)
|
||||||
|
if self.state == State.SELECT_SIDE or self.side != 2:
|
||||||
|
ray.draw_texture(self.textures['entry'][377], 2 + self.textures['entry'][377].width, self.height - self.textures['entry'][376].height + 1, ray.WHITE)
|
||||||
|
|
||||||
|
def draw_side_select(self):
|
||||||
|
left_x, top_y, right_x, bottom_y = 238, 108, 979, 520
|
||||||
|
ray.draw_texture(self.textures['entry'][205], left_x, top_y, ray.WHITE)
|
||||||
|
ray.draw_texture(self.textures['entry'][208], right_x, top_y, ray.WHITE)
|
||||||
|
ray.draw_texture(self.textures['entry'][204], left_x, bottom_y, ray.WHITE)
|
||||||
|
ray.draw_texture(self.textures['entry'][207], right_x, bottom_y, ray.WHITE)
|
||||||
|
|
||||||
|
texture = self.textures['entry'][209]
|
||||||
|
src = ray.Rectangle(0, 0, texture.width, texture.height)
|
||||||
|
dest = ray.Rectangle(left_x + self.textures['entry'][205].width, top_y, right_x - left_x - (self.textures['entry'][205].width), texture.height)
|
||||||
|
ray.draw_texture_pro(texture, src, dest, ray.Vector2(0, 0), 0, ray.WHITE)
|
||||||
|
texture = self.textures['entry'][210]
|
||||||
|
src = ray.Rectangle(0, 0, texture.width, texture.height)
|
||||||
|
dest = ray.Rectangle(left_x + self.textures['entry'][205].width, bottom_y, right_x - left_x - (self.textures['entry'][205].width), texture.height)
|
||||||
|
ray.draw_texture_pro(texture, src, dest, ray.Vector2(0, 0), 0, ray.WHITE)
|
||||||
|
|
||||||
|
texture = self.textures['entry'][203]
|
||||||
|
src = ray.Rectangle(0, 0, texture.width, texture.height)
|
||||||
|
dest = ray.Rectangle(left_x, top_y + self.textures['entry'][205].height, texture.width, bottom_y - top_y - (self.textures['entry'][205].height))
|
||||||
|
ray.draw_texture_pro(texture, src, dest, ray.Vector2(0, 0), 0, ray.WHITE)
|
||||||
|
texture = self.textures['entry'][206]
|
||||||
|
src = ray.Rectangle(0, 0, texture.width, texture.height)
|
||||||
|
dest = ray.Rectangle(right_x, top_y + self.textures['entry'][205].height, texture.width, bottom_y - top_y - (self.textures['entry'][205].height))
|
||||||
|
ray.draw_texture_pro(texture, src, dest, ray.Vector2(0, 0), 0, ray.WHITE)
|
||||||
|
|
||||||
|
texture = self.textures['entry'][202]
|
||||||
|
src = ray.Rectangle(0, 0, texture.width, texture.height)
|
||||||
|
dest = ray.Rectangle(left_x + self.textures['entry'][205].width, top_y + self.textures['entry'][205].height, right_x - left_x - (self.textures['entry'][205].width), bottom_y - top_y - (self.textures['entry'][205].height))
|
||||||
|
ray.draw_texture_pro(texture, src, dest, ray.Vector2(0, 0), 0, ray.WHITE)
|
||||||
|
|
||||||
|
ray.draw_texture(self.textures['entry'][226], 384, 144, ray.WHITE)
|
||||||
|
|
||||||
|
cursor_x = 261
|
||||||
|
cursor_texture = self.textures['entry'][230]
|
||||||
|
flip = 1
|
||||||
|
if self.side == 0:
|
||||||
|
texture = self.textures['entry'][229]
|
||||||
|
flip = -1
|
||||||
|
else:
|
||||||
|
texture = self.textures['entry'][232]
|
||||||
|
ray.draw_texture(texture, 261, 400, ray.WHITE)
|
||||||
|
|
||||||
|
if self.side == 1:
|
||||||
|
texture = self.textures['entry'][76]
|
||||||
|
cursor_texture = self.textures['entry'][77]
|
||||||
|
cursor_x = 512
|
||||||
|
else:
|
||||||
|
texture = self.textures['entry'][228]
|
||||||
|
ray.draw_texture(texture, 512, 400, ray.WHITE)
|
||||||
|
ray.draw_texture(self.textures['entry'][201], 512, 408, ray.WHITE)
|
||||||
|
|
||||||
|
if self.side == 2:
|
||||||
|
texture = self.textures['entry'][233]
|
||||||
|
cursor_x = 762
|
||||||
|
else:
|
||||||
|
texture = self.textures['entry'][227]
|
||||||
|
ray.draw_texture(texture, 762, 400, ray.WHITE)
|
||||||
|
|
||||||
|
src = ray.Rectangle(0, 0, cursor_texture.width * flip, cursor_texture.height)
|
||||||
|
dest = ray.Rectangle(cursor_x, 400, cursor_texture.width, cursor_texture.height)
|
||||||
|
ray.draw_texture_pro(cursor_texture, src, dest, ray.Vector2(0, 0), 0, ray.WHITE)
|
||||||
|
|
||||||
|
def draw_player_drum(self):
|
||||||
|
move_x = 0
|
||||||
|
if self.drum_move_3 is not None:
|
||||||
|
move_x = int(self.drum_move_3.attribute)
|
||||||
|
if self.side == 0:
|
||||||
|
drum_texture = self.textures['entry'][366]
|
||||||
|
x = 160
|
||||||
|
else:
|
||||||
|
drum_texture = self.textures['entry'][367]
|
||||||
|
x = 780
|
||||||
|
move_x = move_x * -1
|
||||||
|
move_y = 0
|
||||||
|
if self.drum_move_1 is not None:
|
||||||
|
move_y = int(self.drum_move_1.attribute)
|
||||||
|
if self.drum_move_2 is not None:
|
||||||
|
move_y += int(self.drum_move_2.attribute)
|
||||||
|
ray.draw_texture(drum_texture, x + move_x, 720 + move_y, ray.WHITE)
|
||||||
|
if self.cloud_resize is not None and not self.cloud_resize.is_finished:
|
||||||
|
scale = self.cloud_resize.attribute
|
||||||
|
else:
|
||||||
|
scale = max(1, self.cloud_resize_loop.attribute)
|
||||||
|
texture_index = 45
|
||||||
|
if self.cloud_texture_change is not None and self.cloud_texture_change.attribute != 0:
|
||||||
|
texture_index = self.cloud_texture_change.attribute
|
||||||
|
color = ray.fade(ray.WHITE, 1.0)
|
||||||
|
if self.cloud_fade is not None:
|
||||||
|
color = ray.fade(ray.WHITE, self.cloud_fade.attribute)
|
||||||
|
draw_scaled_texture(self.textures['entry'][texture_index], x + move_x - int(160 * (scale-1)), 720 + move_y - 200 - int(160 * (scale-1)), scale, color)
|
||||||
|
|
||||||
|
def draw_mode_select(self):
|
||||||
|
self.draw_player_drum()
|
||||||
|
if self.cloud_fade is not None and self.cloud_fade.is_finished:
|
||||||
|
box_width = self.textures['entry'][262].width
|
||||||
|
spacing = 80
|
||||||
|
push_distance = 50
|
||||||
|
total_width = self.num_boxes * box_width + (self.num_boxes - 1) * spacing
|
||||||
|
start_x = self.width//2 - total_width//2
|
||||||
|
y = self.height//2 - (self.textures['entry'][262].height//2) - 15
|
||||||
|
for i in range(self.num_boxes):
|
||||||
|
x_pos = start_x + i * (box_width + spacing)
|
||||||
|
push_offset = 0
|
||||||
|
if i != self.selected_box:
|
||||||
|
if i < self.selected_box:
|
||||||
|
push_offset = -push_distance
|
||||||
|
else:
|
||||||
|
push_offset = push_distance
|
||||||
|
final_x = x_pos + push_offset
|
||||||
|
ray.draw_texture(self.textures['entry'][262], final_x, y, ray.WHITE)
|
||||||
|
if i == self.selected_box:
|
||||||
|
ray.draw_texture(self.textures['entry'][302], final_x, y, ray.WHITE)
|
||||||
|
texture = self.textures['entry'][304]
|
||||||
|
src = ray.Rectangle(0, 0, texture.width, texture.height)
|
||||||
|
dest = ray.Rectangle(final_x + self.textures['entry'][302].width, y, 100 - self.textures['entry'][302].width, texture.height)
|
||||||
|
ray.draw_texture_pro(texture, src, dest, ray.Vector2(0, 0), 0, ray.WHITE)
|
||||||
|
ray.draw_texture(self.textures['entry'][303], final_x+100, y, ray.WHITE)
|
||||||
|
|
||||||
|
box_title = self.box_titles[i][1]
|
||||||
|
src = ray.Rectangle(0, 0, box_title.texture.width, box_title.texture.height)
|
||||||
|
dest = ray.Rectangle(final_x + 12, y + 20, box_title.texture.width, box_title.texture.height)
|
||||||
|
box_title.draw(src, dest, ray.Vector2(0, 0), 0, ray.WHITE)
|
||||||
|
else:
|
||||||
|
box_title = self.box_titles[i][0]
|
||||||
|
src = ray.Rectangle(0, 0, box_title.texture.width, box_title.texture.height)
|
||||||
|
dest = ray.Rectangle(final_x + 9, y + 20, box_title.texture.width, box_title.texture.height)
|
||||||
|
box_title.draw(src, dest, ray.Vector2(0, 0), 0, ray.WHITE)
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
ray.draw_texture(self.texture_footer, 0, self.height - 151, ray.WHITE)
|
self.draw_background()
|
||||||
|
if self.state == State.SELECT_SIDE:
|
||||||
|
self.draw_side_select()
|
||||||
|
elif self.state == State.SELECT_MODE:
|
||||||
|
self.draw_mode_select()
|
||||||
|
self.draw_footer()
|
||||||
|
|
||||||
|
ray.draw_texture(self.textures['entry'][320], 0, 0, ray.WHITE)
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ from libs.utils import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class State:
|
||||||
|
BROWSING = 0
|
||||||
|
SONG_SELECTED = 1
|
||||||
|
|
||||||
class SongSelectScreen:
|
class SongSelectScreen:
|
||||||
BOX_CENTER = 444
|
BOX_CENTER = 444
|
||||||
def __init__(self, screen_width: int, screen_height: int):
|
def __init__(self, screen_width: int, screen_height: int):
|
||||||
@@ -56,7 +60,7 @@ class SongSelectScreen:
|
|||||||
self.move_away = Animation.create_move(float('inf'))
|
self.move_away = Animation.create_move(float('inf'))
|
||||||
self.diff_fade_out = Animation.create_fade(0, final_opacity=1.0)
|
self.diff_fade_out = Animation.create_fade(0, final_opacity=1.0)
|
||||||
self.background_move = Animation.create_move(15000, start_position=0, total_distance=1280)
|
self.background_move = Animation.create_move(15000, start_position=0, total_distance=1280)
|
||||||
self.state = "BROWSING"
|
self.state = State.BROWSING
|
||||||
self.text_fade_out = None
|
self.text_fade_out = None
|
||||||
self.text_fade_in = None
|
self.text_fade_in = None
|
||||||
self.texture_index = 784
|
self.texture_index = 784
|
||||||
@@ -91,7 +95,7 @@ class SongSelectScreen:
|
|||||||
self.demo_song = None
|
self.demo_song = None
|
||||||
self.navigator.get_current_item().box.wait = get_current_ms()
|
self.navigator.get_current_item().box.wait = get_current_ms()
|
||||||
def handle_input(self):
|
def handle_input(self):
|
||||||
if self.state == "BROWSING":
|
if self.state == State.BROWSING:
|
||||||
if ray.is_key_pressed(ray.KeyboardKey.KEY_LEFT_CONTROL) or (is_l_kat_pressed() and get_current_ms() <= self.last_moved + 100):
|
if ray.is_key_pressed(ray.KeyboardKey.KEY_LEFT_CONTROL) or (is_l_kat_pressed() and get_current_ms() <= self.last_moved + 100):
|
||||||
self.reset_demo_music()
|
self.reset_demo_music()
|
||||||
self.wait = get_current_ms()
|
self.wait = get_current_ms()
|
||||||
@@ -126,14 +130,14 @@ class SongSelectScreen:
|
|||||||
else:
|
else:
|
||||||
selected_song = self.navigator.select_current_item()
|
selected_song = self.navigator.select_current_item()
|
||||||
if selected_song:
|
if selected_song:
|
||||||
self.state = "SONG_SELECTED"
|
self.state = State.SONG_SELECTED
|
||||||
if 4 not in selected_song.tja.metadata.course_data:
|
if 4 not in selected_song.tja.metadata.course_data:
|
||||||
self.is_ura = False
|
self.is_ura = False
|
||||||
audio.play_sound(self.sound_don)
|
audio.play_sound(self.sound_don)
|
||||||
self.move_away = Animation.create_move(233, total_distance=500)
|
self.move_away = Animation.create_move(233, total_distance=500)
|
||||||
self.diff_fade_out = Animation.create_fade(83)
|
self.diff_fade_out = Animation.create_fade(83)
|
||||||
|
|
||||||
elif self.state == "SONG_SELECTED":
|
elif self.state == State.SONG_SELECTED:
|
||||||
# Handle song selection confirmation or cancel
|
# Handle song selection confirmation or cancel
|
||||||
if is_l_don_pressed() or is_r_don_pressed():
|
if is_l_don_pressed() or is_r_don_pressed():
|
||||||
if self.selected_difficulty == -1:
|
if self.selected_difficulty == -1:
|
||||||
@@ -142,7 +146,7 @@ class SongSelectScreen:
|
|||||||
self.diff_fade_out = Animation.create_fade(0, final_opacity=1.0)
|
self.diff_fade_out = Animation.create_fade(0, final_opacity=1.0)
|
||||||
self.text_fade_out = None
|
self.text_fade_out = None
|
||||||
self.text_fade_in = None
|
self.text_fade_in = None
|
||||||
self.state = "BROWSING"
|
self.state = State.BROWSING
|
||||||
for item in self.navigator.items:
|
for item in self.navigator.items:
|
||||||
item.box.reset()
|
item.box.reset()
|
||||||
else:
|
else:
|
||||||
@@ -211,7 +215,7 @@ class SongSelectScreen:
|
|||||||
if self.background_fade_change is None:
|
if self.background_fade_change is None:
|
||||||
self.last_texture_index = self.texture_index
|
self.last_texture_index = self.texture_index
|
||||||
for song in self.navigator.items:
|
for song in self.navigator.items:
|
||||||
song.box.update(self.state == "SONG_SELECTED")
|
song.box.update(self.state == State.SONG_SELECTED)
|
||||||
song.box.is_open = song.box.position == SongSelectScreen.BOX_CENTER + 150
|
song.box.is_open = song.box.position == SongSelectScreen.BOX_CENTER + 150
|
||||||
if not isinstance(song, Directory) and song.box.is_open:
|
if not isinstance(song, Directory) and song.box.is_open:
|
||||||
if self.demo_song is None and get_current_ms() >= song.box.wait + (83.33*3):
|
if self.demo_song is None and get_current_ms() >= song.box.wait + (83.33*3):
|
||||||
@@ -283,7 +287,7 @@ class SongSelectScreen:
|
|||||||
if self.ura_switch_animation is not None:
|
if self.ura_switch_animation is not None:
|
||||||
self.ura_switch_animation.draw(self.textures)
|
self.ura_switch_animation.draw(self.textures)
|
||||||
|
|
||||||
if self.selected_song and self.state == "SONG_SELECTED":
|
if self.selected_song and self.state == State.SONG_SELECTED:
|
||||||
self.draw_selector()
|
self.draw_selector()
|
||||||
fade = ray.WHITE
|
fade = ray.WHITE
|
||||||
if self.text_fade_in is not None:
|
if self.text_fade_in is not None:
|
||||||
|
|||||||
@@ -16,6 +16,11 @@ from libs.utils import (
|
|||||||
from libs.video import VideoPlayer
|
from libs.video import VideoPlayer
|
||||||
|
|
||||||
|
|
||||||
|
class State:
|
||||||
|
OP_VIDEO = 0
|
||||||
|
WARNING = 1
|
||||||
|
ATTRACT_VIDEO = 2
|
||||||
|
|
||||||
class TitleScreen:
|
class TitleScreen:
|
||||||
def __init__(self, width: int, height: int):
|
def __init__(self, width: int, height: int):
|
||||||
self.width = width
|
self.width = width
|
||||||
@@ -48,7 +53,7 @@ class TitleScreen:
|
|||||||
if not self.screen_init:
|
if not self.screen_init:
|
||||||
self.screen_init = True
|
self.screen_init = True
|
||||||
self.load_textures()
|
self.load_textures()
|
||||||
self.scene = 'Opening Video'
|
self.state = State.OP_VIDEO
|
||||||
self.op_video = VideoPlayer(random.choice(self.op_video_list))
|
self.op_video = VideoPlayer(random.choice(self.op_video_list))
|
||||||
self.attract_video = VideoPlayer(random.choice(self.attract_video_list))
|
self.attract_video = VideoPlayer(random.choice(self.attract_video_list))
|
||||||
self.warning_board = None
|
self.warning_board = None
|
||||||
@@ -66,7 +71,7 @@ class TitleScreen:
|
|||||||
return "ENTRY"
|
return "ENTRY"
|
||||||
|
|
||||||
def scene_manager(self):
|
def scene_manager(self):
|
||||||
if self.scene == 'Opening Video':
|
if self.state == State.OP_VIDEO:
|
||||||
if not self.op_video.is_started():
|
if not self.op_video.is_started():
|
||||||
self.op_video.start(get_current_ms())
|
self.op_video.start(get_current_ms())
|
||||||
self.op_video.update()
|
self.op_video.update()
|
||||||
@@ -74,20 +79,20 @@ class TitleScreen:
|
|||||||
self.op_video.stop()
|
self.op_video.stop()
|
||||||
self.op_video = VideoPlayer(random.choice(self.op_video_list))
|
self.op_video = VideoPlayer(random.choice(self.op_video_list))
|
||||||
|
|
||||||
self.scene = 'Warning Board'
|
self.state = State.WARNING
|
||||||
self.warning_board = WarningScreen(get_current_ms(), self)
|
self.warning_board = WarningScreen(get_current_ms(), self)
|
||||||
elif self.scene == 'Warning Board' and self.warning_board is not None:
|
elif self.state == State.WARNING and self.warning_board is not None:
|
||||||
self.warning_board.update(get_current_ms(), self)
|
self.warning_board.update(get_current_ms(), self)
|
||||||
if self.warning_board.is_finished:
|
if self.warning_board.is_finished:
|
||||||
self.scene = 'Attract Video'
|
self.state = State.ATTRACT_VIDEO
|
||||||
self.attract_video.start(get_current_ms())
|
self.attract_video.start(get_current_ms())
|
||||||
elif self.scene == 'Attract Video':
|
elif self.state == State.ATTRACT_VIDEO:
|
||||||
self.attract_video.update()
|
self.attract_video.update()
|
||||||
if self.attract_video.is_finished():
|
if self.attract_video.is_finished():
|
||||||
self.attract_video.stop()
|
self.attract_video.stop()
|
||||||
self.attract_video = VideoPlayer(random.choice(self.attract_video_list))
|
self.attract_video = VideoPlayer(random.choice(self.attract_video_list))
|
||||||
|
|
||||||
self.scene = 'Opening Video'
|
self.state = State.OP_VIDEO
|
||||||
self.op_video.start(get_current_ms())
|
self.op_video.start(get_current_ms())
|
||||||
|
|
||||||
|
|
||||||
@@ -99,14 +104,14 @@ class TitleScreen:
|
|||||||
return self.on_screen_end()
|
return self.on_screen_end()
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
if self.scene == 'Opening Video':
|
if self.state == State.OP_VIDEO:
|
||||||
self.op_video.draw()
|
self.op_video.draw()
|
||||||
elif self.scene == 'Warning Board' and self.warning_board is not None:
|
elif self.state == State.WARNING and self.warning_board is not None:
|
||||||
bg_source = ray.Rectangle(0, 0, self.textures['keikoku'][0].width, self.textures['keikoku'][0].height)
|
bg_source = ray.Rectangle(0, 0, self.textures['keikoku'][0].width, self.textures['keikoku'][0].height)
|
||||||
bg_dest = ray.Rectangle(0, 0, self.width, self.height)
|
bg_dest = ray.Rectangle(0, 0, self.width, self.height)
|
||||||
ray.draw_texture_pro(self.textures['keikoku'][0], bg_source, bg_dest, ray.Vector2(0,0), 0, ray.WHITE)
|
ray.draw_texture_pro(self.textures['keikoku'][0], bg_source, bg_dest, ray.Vector2(0,0), 0, ray.WHITE)
|
||||||
self.warning_board.draw(self)
|
self.warning_board.draw(self)
|
||||||
elif self.scene == 'Attract Video':
|
elif self.state == State.ATTRACT_VIDEO:
|
||||||
self.attract_video.draw()
|
self.attract_video.draw()
|
||||||
|
|
||||||
class WarningScreen:
|
class WarningScreen:
|
||||||
|
|||||||
Reference in New Issue
Block a user