Want to contribute? Fork me on Codeberg.org!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
655 B

extends Line2D
var queue: Array
@export var MAX_LENGTH: int
var shrinking = false
@export var OPACITY_SHRINK_RATE = 5
@export var SIZE_SHRINK_RATE = 5
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
queue.push_front(global_position)
if queue.size() > MAX_LENGTH:
queue.pop_back()
clear_points()
for point in queue:
add_point(point - global_position)
if shrinking:
modulate.a = lerpf(modulate.a, 0, OPACITY_SHRINK_RATE * delta)
width = lerpf(width, 0, SIZE_SHRINK_RATE * delta)
$PointLight2D.energy = lerpf($PointLight2D.energy, 0, OPACITY_SHRINK_RATE * delta)
$Sprite2D.visible = false