26 lines
858 B
GDScript
26 lines
858 B
GDScript
class_name CandleCursor extends CPUParticles2D
|
|
|
|
var noise: = FastNoiseLite.new()
|
|
var noise_position:= 0.0
|
|
var noise_offset:= Vector2.ZERO
|
|
|
|
var gamepad_mode: bool = false
|
|
var gamepad_target: Vector2 = Vector2.ZERO
|
|
|
|
var cursor_target: Vector2 = Vector2.ZERO
|
|
|
|
func _process(delta: float) -> void:
|
|
|
|
if gamepad_mode:
|
|
cursor_target -= (cursor_target - gamepad_target) * 4 * delta
|
|
else:
|
|
cursor_target = get_viewport().get_mouse_position()
|
|
|
|
var diff: Vector2 = position - noise_offset - cursor_target
|
|
noise_position += delta * 100
|
|
noise_offset = Vector2(noise.get_noise_1d(noise_position), noise.get_noise_1d(-noise_position))*30.0
|
|
position = cursor_target + noise_offset
|
|
rotation = lerp(rotation, clamp(-PI/3, diff.x *.05, PI/3), delta*20.0)
|
|
|
|
lifetime = max(0.01, lerp(lifetime, .25 * (1.0/(1.0+diff.length()*.1) - noise_offset.length()*.02), 0.2))
|