Randoloot/scripts/game/laser_beam_visual.gd
2026-10-13 19:49:14 +02:00

29 lines
868 B
GDScript

extends Line2D
var _time := 0.0
func _ready() -> void:
# Draw the beam in layers instead of a flat line. No bloom is required.
default_color = Color.TRANSPARENT
width = 0.0
func _process(delta: float) -> void:
_time += delta
if visible:
queue_redraw()
func _draw() -> void:
if points.size() < 2:
return
var start := points[0]
var end := points[1]
var pulse := 0.88 + sin(_time * 65.0) * 0.12
draw_line(start, end, Color(0.1, 0.65, 1.0, 0.09 * pulse), 16, true)
draw_line(start, end, Color(0.15, 0.8, 1.0, 0.2 * pulse), 9, true)
draw_line(start, end, Color(0.3, 0.92, 1.0, 0.7), 3.8, true)
draw_line(start, end, Color(0.9, 1.0, 1.0, 0.96), 1.4, true)
for point in [start, end]:
draw_circle(point, 9 * pulse, Color(0.1, 0.8, 1.0, 0.12))
draw_circle(point, 4 * pulse, Color(0.35, 0.95, 1.0, 0.6))
draw_circle(point, 1.8, Color(0.9, 1.0, 1.0))