mirror of
https://github.com/Yonokid/PyTaiko.git
synced 2026-02-04 11:40:13 +01:00
add song select, results, config, and asio support
This commit is contained in:
41
main.py
41
main.py
@@ -1,9 +1,13 @@
|
||||
import pyray as ray
|
||||
import sys
|
||||
|
||||
from entry import *
|
||||
from game import *
|
||||
from title import *
|
||||
from libs.audio import audio
|
||||
from libs.utils import GlobalData, get_config
|
||||
from scenes.entry import EntryScreen
|
||||
from scenes.game import GameScreen
|
||||
from scenes.result import ResultScreen
|
||||
from scenes.song_select import SongSelectScreen
|
||||
from scenes.title import TitleScreen
|
||||
|
||||
|
||||
class Screens:
|
||||
TITLE = "TITLE"
|
||||
@@ -16,37 +20,42 @@ def main():
|
||||
screen_width = 1280
|
||||
screen_height = 720
|
||||
|
||||
ray.set_config_flags(ray.ConfigFlags.FLAG_VSYNC_HINT)
|
||||
if get_config()["video"]["vsync"]:
|
||||
ray.set_config_flags(ray.ConfigFlags.FLAG_VSYNC_HINT)
|
||||
ray.set_config_flags(ray.ConfigFlags.FLAG_MSAA_4X_HINT)
|
||||
|
||||
ray.set_window_max_size(screen_width, screen_height)
|
||||
ray.set_window_min_size(screen_width, screen_height)
|
||||
ray.init_window(screen_width, screen_height, "PyTaiko")
|
||||
#ray.toggle_borderless_windowed()
|
||||
if get_config()["video"]["borderless"]:
|
||||
ray.toggle_borderless_windowed()
|
||||
ray.clear_window_state(ray.ConfigFlags.FLAG_WINDOW_TOPMOST)
|
||||
#ray.maximize_window()
|
||||
if get_config()["video"]["fullscreen"]:
|
||||
ray.maximize_window()
|
||||
|
||||
current_screen = Screens.TITLE
|
||||
frames_counter = 0
|
||||
_frames_counter = 0
|
||||
|
||||
ray.init_audio_device()
|
||||
audio.init_audio_device()
|
||||
|
||||
title_screen = TitleScreen(screen_width, screen_height)
|
||||
entry_screen = EntryScreen(screen_width, screen_height)
|
||||
song_select_screen = SongSelectScreen(screen_width, screen_height)
|
||||
game_screen = GameScreen(screen_width, screen_height)
|
||||
result_screen = ResultScreen(screen_width, screen_height)
|
||||
|
||||
screen_mapping = {
|
||||
Screens.ENTRY: entry_screen,
|
||||
Screens.TITLE: title_screen,
|
||||
#Screens.SONG_SELECT: song_select_screen,
|
||||
Screens.SONG_SELECT: song_select_screen,
|
||||
Screens.GAME: game_screen,
|
||||
#Screens.RESULT: result_screen
|
||||
Screens.RESULT: result_screen
|
||||
}
|
||||
target = ray.load_render_texture(screen_width, screen_height)
|
||||
ray.set_texture_filter(target.texture, ray.TextureFilter.TEXTURE_FILTER_TRILINEAR)
|
||||
#lmaooooooooooooo
|
||||
#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(0x302, 0x303, 1, 0x303, 0x8006, 0x8006)
|
||||
start_song = False
|
||||
ray.set_exit_key(ray.KeyboardKey.KEY_A)
|
||||
while not ray.window_should_close():
|
||||
|
||||
@@ -60,9 +69,6 @@ def main():
|
||||
elif ray.is_key_pressed(ray.KeyboardKey.KEY_F12):
|
||||
ray.toggle_borderless_windowed()
|
||||
|
||||
if screen == game_screen and not start_song:
|
||||
game_screen.init_tja(sys.argv[1], sys.argv[2])
|
||||
start_song = True
|
||||
next_screen = screen.update()
|
||||
screen.draw()
|
||||
if screen == title_screen:
|
||||
@@ -73,7 +79,8 @@ def main():
|
||||
if next_screen is not None:
|
||||
current_screen = next_screen
|
||||
|
||||
ray.draw_fps(20, 20)
|
||||
if get_config()["general"]["fps_counter"]:
|
||||
ray.draw_fps(20, 20)
|
||||
ray.end_blend_mode()
|
||||
ray.end_texture_mode()
|
||||
ray.begin_drawing()
|
||||
@@ -81,7 +88,7 @@ def main():
|
||||
ray.draw_texture_pro(target.texture, ray.Rectangle(0, 0, target.texture.width, -target.texture.height), ray.Rectangle(0, 0, ray.get_render_width(), ray.get_render_height()), ray.Vector2(0,0), 0, ray.WHITE)
|
||||
ray.end_drawing()
|
||||
ray.close_window()
|
||||
ray.close_audio_device()
|
||||
audio.close_audio_device()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user