From 7f40d324a6c93d11dcfd0dd1b2b8f679915d616c Mon Sep 17 00:00:00 2001 From: unfa Date: Sat, 18 Dec 2021 14:26:22 +0100 Subject: [PATCH] Added FPS=5 limit when the game window is not active. --- Game/Assets/HUD/Performance.gd | 2 ++ Game/Main.gd | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/Game/Assets/HUD/Performance.gd b/Game/Assets/HUD/Performance.gd index a266cdf..c2e7077 100644 --- a/Game/Assets/HUD/Performance.gd +++ b/Game/Assets/HUD/Performance.gd @@ -39,4 +39,6 @@ func _process(delta): text += "\nFPS: " + str(Engine.get_frames_per_second()) + if Engine.target_fps != 0: + text += " (capped at " + str(Engine.target_fps) + ")" text += "\n" + version + " ยท https://git.gieszer.link/unfa/liblast" diff --git a/Game/Main.gd b/Game/Main.gd index c1e7548..0f4d500 100644 --- a/Game/Main.gd +++ b/Game/Main.gd @@ -77,6 +77,14 @@ var game_score_limit = 10 #15 const destroy_free_player_crash_workaround = true +func _notification(what: int) -> void: + match what: + NOTIFICATION_APPLICATION_FOCUS_OUT: + Engine.target_fps = 5 + NOTIFICATION_APPLICATION_FOCUS_IN: + # `0` means "unlimited". + Engine.target_fps = 0 + func _process(delta): uptime += delta