Code cleanup and minor fixes to Level 3
This commit is contained in:
@@ -1,17 +1,16 @@
|
||||
extends Node
|
||||
|
||||
const END_VALUE = 1
|
||||
|
||||
signal unfreeze
|
||||
|
||||
var is_active = false
|
||||
var time_start
|
||||
var duration_ms
|
||||
var start_value
|
||||
const END_VALUE: int = 1
|
||||
|
||||
var is_active: bool = false
|
||||
var time_start: int
|
||||
var duration_ms: int
|
||||
var start_value: float
|
||||
|
||||
|
||||
|
||||
func start(duration = 1, strength = 0.9):
|
||||
func start(duration: int = 1, strength: float = 0.9):
|
||||
time_start = OS.get_ticks_msec()
|
||||
duration_ms = duration * 1000
|
||||
start_value = 1 - strength
|
||||
@@ -19,7 +18,7 @@ func start(duration = 1, strength = 0.9):
|
||||
is_active = true
|
||||
|
||||
|
||||
func _process(delta):
|
||||
func _process(_delta: float) -> void:
|
||||
if is_active:
|
||||
var current_time = OS.get_ticks_msec() - time_start
|
||||
var value = circl_ease_in(current_time, start_value, END_VALUE, duration_ms)
|
||||
@@ -28,7 +27,9 @@ func _process(delta):
|
||||
value = END_VALUE
|
||||
emit_signal('unfreeze')
|
||||
Engine.time_scale = value
|
||||
|
||||
return
|
||||
|
||||
|
||||
func circl_ease_in(t, b, c, d):
|
||||
t /=d
|
||||
t /= d
|
||||
return -c * (sqrt(1 - t * t) - 1) + b
|
||||
|
Reference in New Issue
Block a user