mirror of
https://github.com/csd4ni3l/ember-keeper.git
synced 2026-01-01 04:23:43 +01:00
fix best time not loading due to not using level num, update README, lock the game to 60 FPS, add hitboxes setting and camera shake
This commit is contained in:
27
run.py
27
run.py
@@ -14,13 +14,10 @@ pyglet.font.add_directory(os.path.join(script_dir, 'assets', 'fonts'))
|
||||
from utils.utils import get_closest_resolution, print_debug_info, on_exception
|
||||
from utils.constants import log_dir, menu_background_color
|
||||
from menus.main import Main
|
||||
# from utils.preload import theme_sound # needed for preload
|
||||
from arcade.experimental.controller_window import ControllerWindow
|
||||
|
||||
sys.excepthook = on_exception
|
||||
|
||||
# __builtins__.print = lambda *args, **kwargs: logging.debug(" ".join(map(str, args)))
|
||||
|
||||
if not log_dir in os.listdir():
|
||||
os.makedirs(log_dir)
|
||||
|
||||
@@ -58,7 +55,6 @@ if os.path.exists('settings.json'):
|
||||
fullscreen = settings['window_mode'] == 'Fullscreen'
|
||||
style = arcade.Window.WINDOW_STYLE_BORDERLESS if settings['window_mode'] == 'borderless' else arcade.Window.WINDOW_STYLE_DEFAULT
|
||||
vsync = settings['vsync']
|
||||
fps_limit = settings['fps_limit']
|
||||
else:
|
||||
resolution = get_closest_resolution()
|
||||
antialiasing = 4
|
||||
@@ -73,7 +69,6 @@ else:
|
||||
fullscreen = False
|
||||
style = arcade.Window.WINDOW_STYLE_DEFAULT
|
||||
vsync = True
|
||||
fps_limit = 0
|
||||
|
||||
settings = {
|
||||
"music": True,
|
||||
@@ -81,38 +76,20 @@ else:
|
||||
"resolution": f"{resolution[0]}x{resolution[1]}",
|
||||
"antialiasing": "4x MSAA",
|
||||
"window_mode": "Windowed",
|
||||
"vsync": True,
|
||||
"fps_limit": 60,
|
||||
"discord_rpc": True
|
||||
}
|
||||
|
||||
with open("settings.json", "w") as file:
|
||||
file.write(json.dumps(settings))
|
||||
|
||||
# if settings.get("music", True):
|
||||
# theme_sound.play(volume=settings.get("music_volume", 50) / 100, loop=True)
|
||||
|
||||
try:
|
||||
window = ControllerWindow(width=resolution[0], height=resolution[1], title='Ember Keeper', samples=antialiasing, antialiasing=antialiasing > 0, fullscreen=fullscreen, vsync=vsync, resizable=False, style=style, visible=False)
|
||||
except (FileNotFoundError, PermissionError) as e:
|
||||
logging.warning(f"Controller support unavailable: {e}. Falling back to regular window.")
|
||||
window = arcade.Window(width=resolution[0], height=resolution[1], title='Ember Keeper', samples=antialiasing, antialiasing=antialiasing > 0, fullscreen=fullscreen, vsync=vsync, resizable=False, style=style, visible=False)
|
||||
|
||||
if vsync:
|
||||
window.set_vsync(True)
|
||||
display_mode = window.display.get_default_screen().get_mode()
|
||||
if display_mode:
|
||||
refresh_rate = display_mode.rate
|
||||
else:
|
||||
refresh_rate = 60
|
||||
window.set_update_rate(1 / refresh_rate)
|
||||
window.set_draw_rate(1 / refresh_rate)
|
||||
elif not fps_limit == 0:
|
||||
window.set_update_rate(1 / fps_limit)
|
||||
window.set_draw_rate(1 / fps_limit)
|
||||
else:
|
||||
window.set_update_rate(1 / 99999999)
|
||||
window.set_draw_rate(1 / 99999999)
|
||||
window.set_update_rate(1 / 60)
|
||||
window.set_draw_rate(1 / 60)
|
||||
|
||||
arcade.set_background_color(menu_background_color)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user