extends PointLight2D

# Flicker parameters
@export var flicker_speed: float = 10.0 # How fast the flicker changes
@export var flicker_intensity: float = 0.3 # How much it flickers (0-1)
@export var base_energy: float = 1.0 # Base brightness

# For smooth variation
var time_passed: float = 0.0

func _ready():
	# Store the initial energy value
	energy = base_energy

func _process(delta):
	time_passed += delta * flicker_speed
	
	# Use Perlin-like noise for natural flickering
	var flicker = sin(time_passed) * 0.5 + 0.5 # 0 to 1
	flicker += sin(time_passed * 2.3) * 0.3 # Add secondary variation
	flicker += sin(time_passed * 4.7) * 0.2 # Add tertiary variation
	flicker /= 2.0 # Normalize
	
	# Apply flicker to energy
	energy = base_energy + (flicker - 0.5) * flicker_intensity * 2.0