extends CharacterBody2D

var angular_velocity:float = 0.0

func _process(delta: float) -> void:
	velocity = velocity.lerp(Vector2.ZERO, delta * 5.0)
	
	if angular_velocity > 0:
		rotation += angular_velocity * delta
		angular_velocity = lerp(angular_velocity, 0.0, delta * 2.0)
	if abs(velocity.x) < 1.0 and abs(velocity.y) < 1.0:
		await get_tree().create_timer(2.0).timeout
		var fade_tween = create_tween() 
		fade_tween.set_trans(Tween.TRANS_CUBIC)
		fade_tween.set_ease(Tween.EASE_OUT)
		fade_tween.tween_property($Sprite2D, "modulate:a", 0.0, 2.0)
		await fade_tween.finished
		call_deferred("queue_free")
		pass
	
	move_and_slide()
	pass
