32 lines
803 B
GDScript
32 lines
803 B
GDScript
extends Control
|
|
|
|
export var scale = 2 setget set_scale
|
|
export var upThreshold = 1.0/Engine.iterations_per_second
|
|
export var downThreshold = 1.0/30.0
|
|
|
|
export var delay = 1.0
|
|
|
|
func _ready():
|
|
set_scale(scale)
|
|
$"/root/Music/BGM".play()
|
|
|
|
func _process(delta):
|
|
# Give the system time to adjust
|
|
if delay > 0:
|
|
delay -= delta
|
|
return
|
|
if delta > downThreshold:
|
|
print("GPU is taking too much (", delta, "s < ", downThreshold, "s), adjusting shader scale")
|
|
set_scale(scale+1)
|
|
elif delta < upThreshold and scale > 1:
|
|
print("GPU is taking it easy (", delta, "s < ", upThreshold, "s), adjusting shader scale")
|
|
set_scale(scale-1)
|
|
|
|
func set_scale(val):
|
|
scale = val
|
|
$Viewport.size = rect_size / scale
|
|
$Background.update()
|
|
|
|
func _on_resized():
|
|
$Viewport.size = rect_size / scale
|
|
$Background.update()
|