Level Functionality Complete
This commit is contained in:
34
Levels/SlowTime.gd
Normal file
34
Levels/SlowTime.gd
Normal file
@@ -0,0 +1,34 @@
|
||||
extends Node
|
||||
|
||||
const END_VALUE = 1
|
||||
|
||||
signal unfreeze
|
||||
|
||||
var is_active = false
|
||||
var time_start
|
||||
var duration_ms
|
||||
var start_value
|
||||
|
||||
|
||||
|
||||
func start(duration = 1, strength = 0.9):
|
||||
time_start = OS.get_ticks_msec()
|
||||
duration_ms = duration * 1000
|
||||
start_value = 1 - strength
|
||||
Engine.time_scale = start_value
|
||||
is_active = true
|
||||
|
||||
|
||||
func _process(delta):
|
||||
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)
|
||||
if current_time >= duration_ms:
|
||||
is_active = false
|
||||
value = END_VALUE
|
||||
emit_signal('unfreeze')
|
||||
Engine.time_scale = value
|
||||
|
||||
func circl_ease_in(t, b, c, d):
|
||||
t /=d
|
||||
return -c * (sqrt(1 - t * t) - 1) + b
|
Reference in New Issue
Block a user