37 lines
1.4 KiB
GDScript
37 lines
1.4 KiB
GDScript
extends Node2D
|
|
|
|
const VFX := preload("res://scripts/game/extension_vfx.gd")
|
|
var color := Color("ffb15c")
|
|
var direction := Vector2.DOWN
|
|
var blast := false
|
|
var _age := 0.0
|
|
var _particles: Array[Dictionary] = []
|
|
|
|
func _ready() -> void:
|
|
z_index = 26
|
|
var rng := RandomNumberGenerator.new()
|
|
rng.randomize()
|
|
for index in (28 if blast else 14):
|
|
var ray := Vector2.RIGHT.rotated(rng.randf_range(0, TAU)) if blast else direction.rotated(rng.randf_range(-1.0, 1.0))
|
|
_particles.append({"velocity": ray * rng.randf_range(45, 155), "size": rng.randf_range(1.0, 2.3)})
|
|
|
|
func _process(delta: float) -> void:
|
|
_age += delta
|
|
queue_redraw()
|
|
if _age >= (0.8 if blast else 0.4):
|
|
queue_free()
|
|
|
|
func _draw() -> void:
|
|
var life := 0.8 if blast else 0.4
|
|
var progress := clampf(_age / life, 0, 1)
|
|
var fade := pow(1.0 - progress, 2)
|
|
var radius := (65.0 if blast else 35.0) * (0.4 + progress)
|
|
draw_texture_rect(VFX.radial_texture(), Rect2(-radius, -radius, radius * 2, radius * 2), false, Color(color, fade * 0.9))
|
|
if blast:
|
|
draw_arc(Vector2.ZERO, 8.0 + progress * 80.0, 0, TAU, 64, Color(color, fade * 0.6), 2.0, true)
|
|
draw_arc(Vector2.ZERO, 5.0 + progress * 55.0, 0, TAU, 64, Color("fff2d3", fade * 0.35), 1.0, true)
|
|
for particle in _particles:
|
|
var velocity: Vector2 = particle["velocity"]
|
|
var point := velocity * _age * (1.0 - progress * 0.35)
|
|
draw_line(point, point - velocity.normalized() * (3.0 + 7.0 * fade), Color(color, fade), float(particle["size"]), true)
|