mirror of
https://github.com/Yonokid/PyTaiko.git
synced 2026-02-04 11:40:13 +01:00
minor bug fix
This commit is contained in:
@@ -19,7 +19,7 @@ from libs.utils import (
|
|||||||
from scenes.devtest import DevScreen
|
from scenes.devtest import DevScreen
|
||||||
from scenes.entry import EntryScreen
|
from scenes.entry import EntryScreen
|
||||||
from scenes.game import GameScreen
|
from scenes.game import GameScreen
|
||||||
from scenes.game_2p import TwoPlayerGameScreen
|
from scenes.two_player.game import TwoPlayerGameScreen
|
||||||
from scenes.loading import LoadScreen
|
from scenes.loading import LoadScreen
|
||||||
from scenes.result import ResultScreen
|
from scenes.result import ResultScreen
|
||||||
from scenes.settings import SettingsScreen
|
from scenes.settings import SettingsScreen
|
||||||
@@ -129,7 +129,7 @@ def main():
|
|||||||
ray.set_texture_filter(target.texture, ray.TextureFilter.TEXTURE_FILTER_TRILINEAR)
|
ray.set_texture_filter(target.texture, ray.TextureFilter.TEXTURE_FILTER_TRILINEAR)
|
||||||
ray.gen_texture_mipmaps(target.texture)
|
ray.gen_texture_mipmaps(target.texture)
|
||||||
ray.rl_set_blend_factors_separate(RL_SRC_ALPHA, RL_ONE_MINUS_SRC_ALPHA, RL_ONE, RL_ONE_MINUS_SRC_ALPHA, RL_FUNC_ADD, RL_FUNC_ADD)
|
ray.rl_set_blend_factors_separate(RL_SRC_ALPHA, RL_ONE_MINUS_SRC_ALPHA, RL_ONE, RL_ONE_MINUS_SRC_ALPHA, RL_FUNC_ADD, RL_FUNC_ADD)
|
||||||
ray.set_exit_key(ord(global_data.config["keys"]["exit_key"]))
|
ray.set_exit_key(ord(global_data.config["keys_1p"]["exit_key"]))
|
||||||
|
|
||||||
while not ray.window_should_close():
|
while not ray.window_should_close():
|
||||||
if ray.is_key_pressed(ray.KeyboardKey.KEY_F11):
|
if ray.is_key_pressed(ray.KeyboardKey.KEY_F11):
|
||||||
|
|||||||
@@ -25,6 +25,12 @@ left_don = ['F']
|
|||||||
right_don = ['J']
|
right_don = ['J']
|
||||||
right_kat = ['K']
|
right_kat = ['K']
|
||||||
|
|
||||||
|
[keys_2p]
|
||||||
|
left_kat = ["Z"]
|
||||||
|
left_don = ["X"]
|
||||||
|
right_don = ["C"]
|
||||||
|
right_kat = ["V"]
|
||||||
|
|
||||||
[gamepad]
|
[gamepad]
|
||||||
left_kat = [10]
|
left_kat = [10]
|
||||||
left_don = [16]
|
left_don = [16]
|
||||||
|
|||||||
12
libs/tja.py
12
libs/tja.py
@@ -7,6 +7,7 @@ from dataclasses import dataclass, field, fields
|
|||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from libs.global_data import Modifiers
|
||||||
from libs.utils import get_pixels_per_frame, global_data, strip_comments
|
from libs.utils import get_pixels_per_frame, global_data, strip_comments
|
||||||
|
|
||||||
|
|
||||||
@@ -818,7 +819,6 @@ class TJAParser:
|
|||||||
bisect.insort(curr_draw_list, note, key=lambda x: x.load_ms)
|
bisect.insort(curr_draw_list, note, key=lambda x: x.load_ms)
|
||||||
self.get_moji(curr_note_list, ms_per_measure)
|
self.get_moji(curr_note_list, ms_per_measure)
|
||||||
index += 1
|
index += 1
|
||||||
# https://stackoverflow.com/questions/72899/how-to-sort-a-list-of-dictionaries-by-a-value-of-the-dictionary-in-python
|
|
||||||
# Sorting by load_ms is necessary for drawing, as some notes appear on the
|
# Sorting by load_ms is necessary for drawing, as some notes appear on the
|
||||||
# screen slower regardless of when they reach the judge circle
|
# screen slower regardless of when they reach the judge circle
|
||||||
# Bars can be sorted like this because they don't need hit detection
|
# Bars can be sorted like this because they don't need hit detection
|
||||||
@@ -887,12 +887,12 @@ def modifier_random(notes: NoteList, value: int):
|
|||||||
modded_notes[i].type = type_mapping[modded_notes[i].type]
|
modded_notes[i].type = type_mapping[modded_notes[i].type]
|
||||||
return modded_notes
|
return modded_notes
|
||||||
|
|
||||||
def apply_modifiers(notes: NoteList):
|
def apply_modifiers(notes: NoteList, modifiers: Modifiers):
|
||||||
"""Applies all selected modifiers from global_data to the given NoteList."""
|
"""Applies all selected modifiers from global_data to the given NoteList."""
|
||||||
if global_data.modifiers.display:
|
if modifiers.display:
|
||||||
draw_notes = modifier_display(notes)
|
draw_notes = modifier_display(notes)
|
||||||
if global_data.modifiers.inverse:
|
if modifiers.inverse:
|
||||||
play_notes = modifier_inverse(notes)
|
play_notes = modifier_inverse(notes)
|
||||||
play_notes = modifier_random(notes, global_data.modifiers.random)
|
play_notes = modifier_random(notes, modifiers.random)
|
||||||
draw_notes, bars = modifier_speed(notes, global_data.modifiers.speed)
|
draw_notes, bars = modifier_speed(notes, modifiers.speed)
|
||||||
return deque(play_notes), deque(draw_notes), deque(bars)
|
return deque(play_notes), deque(draw_notes), deque(bars)
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ def is_l_don_pressed() -> bool:
|
|||||||
"""Check if the left don button is pressed"""
|
"""Check if the left don button is pressed"""
|
||||||
if global_data.input_locked:
|
if global_data.input_locked:
|
||||||
return False
|
return False
|
||||||
keys = global_data.config["keys"]["left_don"]
|
keys = global_data.config["keys_1p"]["left_don"]
|
||||||
gamepad_buttons = global_data.config["gamepad"]["left_don"]
|
gamepad_buttons = global_data.config["gamepad"]["left_don"]
|
||||||
for key in keys:
|
for key in keys:
|
||||||
if ray.is_key_pressed(ord(key)):
|
if ray.is_key_pressed(ord(key)):
|
||||||
@@ -121,7 +121,7 @@ def is_r_don_pressed() -> bool:
|
|||||||
"""Check if the right don button is pressed"""
|
"""Check if the right don button is pressed"""
|
||||||
if global_data.input_locked:
|
if global_data.input_locked:
|
||||||
return False
|
return False
|
||||||
keys = global_data.config["keys"]["right_don"]
|
keys = global_data.config["keys_1p"]["right_don"]
|
||||||
gamepad_buttons = global_data.config["gamepad"]["right_don"]
|
gamepad_buttons = global_data.config["gamepad"]["right_don"]
|
||||||
for key in keys:
|
for key in keys:
|
||||||
if ray.is_key_pressed(ord(key)):
|
if ray.is_key_pressed(ord(key)):
|
||||||
@@ -148,7 +148,7 @@ def is_l_kat_pressed() -> bool:
|
|||||||
"""Check if the left kat button is pressed"""
|
"""Check if the left kat button is pressed"""
|
||||||
if global_data.input_locked:
|
if global_data.input_locked:
|
||||||
return False
|
return False
|
||||||
keys = global_data.config["keys"]["left_kat"]
|
keys = global_data.config["keys_1p"]["left_kat"]
|
||||||
gamepad_buttons = global_data.config["gamepad"]["left_kat"]
|
gamepad_buttons = global_data.config["gamepad"]["left_kat"]
|
||||||
for key in keys:
|
for key in keys:
|
||||||
if ray.is_key_pressed(ord(key)):
|
if ray.is_key_pressed(ord(key)):
|
||||||
@@ -175,7 +175,7 @@ def is_r_kat_pressed() -> bool:
|
|||||||
"""Check if the right kat button is pressed"""
|
"""Check if the right kat button is pressed"""
|
||||||
if global_data.input_locked:
|
if global_data.input_locked:
|
||||||
return False
|
return False
|
||||||
keys = global_data.config["keys"]["right_kat"]
|
keys = global_data.config["keys_1p"]["right_kat"]
|
||||||
gamepad_buttons = global_data.config["gamepad"]["right_kat"]
|
gamepad_buttons = global_data.config["gamepad"]["right_kat"]
|
||||||
for key in keys:
|
for key in keys:
|
||||||
if ray.is_key_pressed(ord(key)):
|
if ray.is_key_pressed(ord(key)):
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ from libs.animation import Animation
|
|||||||
from libs.audio import audio
|
from libs.audio import audio
|
||||||
from libs.background import Background
|
from libs.background import Background
|
||||||
from libs.chara_2d import Chara2D
|
from libs.chara_2d import Chara2D
|
||||||
|
from libs.global_data import Modifiers
|
||||||
from libs.global_objects import AllNetIcon, Nameplate
|
from libs.global_objects import AllNetIcon, Nameplate
|
||||||
from libs.texture import tex
|
from libs.texture import tex
|
||||||
from libs.tja import (
|
from libs.tja import (
|
||||||
@@ -81,7 +82,7 @@ class GameScreen:
|
|||||||
if self.tja.metadata.wave.exists() and self.tja.metadata.wave.is_file() and self.song_music is None:
|
if self.tja.metadata.wave.exists() and self.tja.metadata.wave.is_file() and self.song_music is None:
|
||||||
self.song_music = audio.load_music_stream(self.tja.metadata.wave, 'song')
|
self.song_music = audio.load_music_stream(self.tja.metadata.wave, 'song')
|
||||||
|
|
||||||
self.player_1 = Player(self.tja, global_data.player_num, difficulty, False)
|
self.player_1 = Player(self.tja, global_data.player_num, difficulty, False, global_data.modifiers)
|
||||||
self.start_ms = (get_current_ms() - self.tja.metadata.offset*1000)
|
self.start_ms = (get_current_ms() - self.tja.metadata.offset*1000)
|
||||||
|
|
||||||
def on_screen_start(self):
|
def on_screen_start(self):
|
||||||
@@ -217,7 +218,6 @@ class GameScreen:
|
|||||||
audio.update_music_stream(self.song_music)
|
audio.update_music_stream(self.song_music)
|
||||||
|
|
||||||
self.player_1.update(self.current_ms, current_time, self.background)
|
self.player_1.update(self.current_ms, current_time, self.background)
|
||||||
self.player_2.update(self.current_ms, current_time, self.background)
|
|
||||||
self.song_info.update(current_time)
|
self.song_info.update(current_time)
|
||||||
self.result_transition.update(current_time)
|
self.result_transition.update(current_time)
|
||||||
if self.result_transition.is_finished and not audio.is_sound_playing('result_transition'):
|
if self.result_transition.is_finished and not audio.is_sound_playing('result_transition'):
|
||||||
@@ -262,14 +262,14 @@ class Player:
|
|||||||
TIMING_OK_EASY = 108.441665649414
|
TIMING_OK_EASY = 108.441665649414
|
||||||
TIMING_BAD_EASY = 125.125
|
TIMING_BAD_EASY = 125.125
|
||||||
|
|
||||||
def __init__(self, tja: TJAParser, player_number: int, difficulty: int, is_2p: bool):
|
def __init__(self, tja: TJAParser, player_number: int, difficulty: int, is_2p: bool, modifiers: Modifiers):
|
||||||
self.is_2p = is_2p
|
self.is_2p = is_2p
|
||||||
self.player_number = str(player_number)
|
self.player_number = str(player_number)
|
||||||
self.difficulty = difficulty
|
self.difficulty = difficulty
|
||||||
self.visual_offset = global_data.config["general"]["visual_offset"]
|
self.visual_offset = global_data.config["general"]["visual_offset"]
|
||||||
|
|
||||||
notes, self.branch_m, self.branch_e, self.branch_n = tja.notes_to_position(self.difficulty)
|
notes, self.branch_m, self.branch_e, self.branch_n = tja.notes_to_position(self.difficulty)
|
||||||
self.play_notes, self.draw_note_list, self.draw_bar_list = apply_modifiers(notes)
|
self.play_notes, self.draw_note_list, self.draw_bar_list = apply_modifiers(notes, modifiers)
|
||||||
self.end_time = 0
|
self.end_time = 0
|
||||||
if self.play_notes:
|
if self.play_notes:
|
||||||
self.end_time = self.play_notes[-1].hit_ms
|
self.end_time = self.play_notes[-1].hit_ms
|
||||||
|
|||||||
@@ -1,82 +0,0 @@
|
|||||||
import copy
|
|
||||||
from pathlib import Path
|
|
||||||
from libs.tja import TJAParser
|
|
||||||
from libs.utils import get_current_ms
|
|
||||||
from libs.audio import audio
|
|
||||||
from libs.utils import global_data, session_data
|
|
||||||
from libs.video import VideoPlayer
|
|
||||||
from scenes.game import ClearAnimation, FCAnimation, FailAnimation, GameScreen, Player, Background, SCREEN_WIDTH
|
|
||||||
|
|
||||||
class TwoPlayerGameScreen(GameScreen):
|
|
||||||
def on_screen_start(self):
|
|
||||||
if not self.screen_init:
|
|
||||||
super().on_screen_start()
|
|
||||||
scene_preset = self.tja.metadata.scene_preset
|
|
||||||
if self.background is not None:
|
|
||||||
self.background.unload()
|
|
||||||
self.background = Background(3, self.bpm, scene_preset=scene_preset)
|
|
||||||
|
|
||||||
def load_hitsounds(self):
|
|
||||||
"""Load the hit sounds"""
|
|
||||||
sounds_dir = Path("Sounds")
|
|
||||||
if global_data.hit_sound == -1:
|
|
||||||
audio.load_sound(Path('none.wav'), 'hitsound_don_1p')
|
|
||||||
audio.load_sound(Path('none.wav'), 'hitsound_kat_1p')
|
|
||||||
if global_data.hit_sound == 0:
|
|
||||||
audio.load_sound(sounds_dir / "hit_sounds" / str(global_data.hit_sound) / "don.wav", 'hitsound_don_1p')
|
|
||||||
audio.load_sound(sounds_dir / "hit_sounds" / str(global_data.hit_sound) / "ka.wav", 'hitsound_kat_1p')
|
|
||||||
audio.set_sound_pan('hitsound_don_1p', 1.0)
|
|
||||||
audio.set_sound_pan('hitsound_kat_1p', 1.0)
|
|
||||||
audio.load_sound(sounds_dir / "hit_sounds" / str(global_data.hit_sound) / "don_2p.wav", 'hitsound_don_2p')
|
|
||||||
audio.load_sound(sounds_dir / "hit_sounds" / str(global_data.hit_sound) / "ka_2p.wav", 'hitsound_kat_2p')
|
|
||||||
audio.set_sound_pan('hitsound_don_2p', 0.0)
|
|
||||||
audio.set_sound_pan('hitsound_kat_2p', 0.0)
|
|
||||||
else:
|
|
||||||
audio.load_sound(sounds_dir / "hit_sounds" / str(global_data.hit_sound) / "don.ogg", 'hitsound_don_1p')
|
|
||||||
audio.load_sound(sounds_dir / "hit_sounds" / str(global_data.hit_sound) / "ka.ogg", 'hitsound_kat_1p')
|
|
||||||
|
|
||||||
def init_tja(self, song: Path, difficulty: int):
|
|
||||||
"""Initialize the TJA file"""
|
|
||||||
self.tja = TJAParser(song, start_delay=self.start_delay, distance=SCREEN_WIDTH - GameScreen.JUDGE_X)
|
|
||||||
if self.tja.metadata.bgmovie != Path() and self.tja.metadata.bgmovie.exists():
|
|
||||||
self.movie = VideoPlayer(self.tja.metadata.bgmovie)
|
|
||||||
self.movie.set_volume(0.0)
|
|
||||||
else:
|
|
||||||
self.movie = None
|
|
||||||
session_data.song_title = self.tja.metadata.title.get(global_data.config['general']['language'].lower(), self.tja.metadata.title['en'])
|
|
||||||
if self.tja.metadata.wave.exists() and self.tja.metadata.wave.is_file() and self.song_music is None:
|
|
||||||
self.song_music = audio.load_music_stream(self.tja.metadata.wave, 'song')
|
|
||||||
|
|
||||||
tja_copy = copy.deepcopy(self.tja)
|
|
||||||
self.player_1 = Player(self.tja, 1, difficulty, False)
|
|
||||||
self.player_2 = Player(tja_copy, 2, difficulty-1, True)
|
|
||||||
self.start_ms = (get_current_ms() - self.tja.metadata.offset*1000)
|
|
||||||
|
|
||||||
def spawn_ending_anims(self):
|
|
||||||
if session_data.result_bad == 0:
|
|
||||||
self.player_1.ending_anim = FCAnimation(self.player_1.is_2p)
|
|
||||||
self.player_2.ending_anim = FCAnimation(self.player_2.is_2p)
|
|
||||||
elif self.player_1.gauge.is_clear:
|
|
||||||
self.player_1.ending_anim = ClearAnimation(self.player_1.is_2p)
|
|
||||||
self.player_2.ending_anim = ClearAnimation(self.player_2.is_2p)
|
|
||||||
elif not self.player_1.gauge.is_clear:
|
|
||||||
self.player_1.ending_anim = FailAnimation(self.player_1.is_2p)
|
|
||||||
self.player_2.ending_anim = FailAnimation(self.player_2.is_2p)
|
|
||||||
|
|
||||||
def update_background(self, current_time):
|
|
||||||
if self.movie is not None:
|
|
||||||
self.movie.update()
|
|
||||||
else:
|
|
||||||
if len(self.player_1.current_bars) > 0:
|
|
||||||
self.bpm = self.player_1.bpm
|
|
||||||
if self.background is not None:
|
|
||||||
self.background.update(current_time, self.bpm, self.player_1.gauge, self.player_2.gauge)
|
|
||||||
|
|
||||||
def draw(self):
|
|
||||||
if self.movie is not None:
|
|
||||||
self.movie.draw()
|
|
||||||
elif self.background is not None:
|
|
||||||
self.background.draw()
|
|
||||||
self.player_1.draw(self.current_ms, self.start_ms, self.mask_shader)
|
|
||||||
self.player_2.draw(self.current_ms, self.start_ms, self.mask_shader)
|
|
||||||
self.draw_overlay()
|
|
||||||
Reference in New Issue
Block a user