1
0
mirror of https://github.com/JohnBreaux/Boat-Battle.git synced 2024-11-14 21:15:58 +00:00

INFINITE POWER SAVINGS: Reduce idle CPU usage to 0 with this one weird trick

This commit is contained in:
John 2021-11-08 12:17:13 -06:00
parent 89aa8a6b14
commit c1f49fd7bf
2 changed files with 14 additions and 3 deletions

View File

@ -4,6 +4,7 @@ extends Control
var debug_canvas
var debug_active = false
var menu_moving = false
var menu_position = 0.0
var menu_velocity = 4
@ -104,6 +105,7 @@ signal history_event(text)
# returns: void
func _ready():
debug_canvas = get_node("debug_canvas")
debug_canvas.set_transform(menu_hidden) #initialize the debug menu as hidden
command_help([""])
debug_print_line("> ")
@ -114,16 +116,21 @@ func _process(delta):
if (debug_active && menu_position < 1):
# Move the menu down
menu_position += menu_velocity * delta;
menu_moving = true
$debug_canvas/VBoxContainer/LineEdit.grab_focus()
elif (!debug_active && menu_position > 0):
# Move the menu up
menu_position -= menu_velocity * delta;
menu_moving = true
# Clear the input box
emit_signal("clear_in")
else:
elif (menu_position < 0 || menu_position > 1):
menu_position = round(menu_position)
debug_canvas.set_transform(menu_hidden.interpolate_with(menu_active, menu_position))
menu_moving = true
else:
menu_moving = false
if menu_moving:
debug_canvas.set_transform(menu_hidden.interpolate_with(menu_active, menu_position))
# _input: Process user input related to the debug menu
# params: event: The input event which triggered _input call

View File

@ -6,6 +6,7 @@ onready var gameplay = preload("res://scenes/Gameplay.tscn" )
onready var options = preload("res://scenes/Options.tscn" )
onready var debug_menu = preload("res://scenes/Debug Menu.tscn" )
var power_saving = true
var debug_enabled = true
var start_fullscreen = false
@ -20,6 +21,9 @@ func _ready():
_errno += MessageBus.connect("quit" , self, "_on_quit_request" )
_errno += MessageBus.connect("return_to_title", self, "_on_title_request" )
# go fullscreen
if power_saving:
OS.low_processor_usage_mode = true
OS.low_processor_usage_mode_sleep_usec = 6800
if start_fullscreen:
OS.window_fullscreen = true
if debug_enabled: