extends Camera2D

var shake_duration: float = 0.5
var shake_magnitude: float = 10.0
var shake_timer: float = 0.0
var original_position: Vector2

func _ready():
	original_position = position

func _process(delta: float) -> void:
	if shake_timer > 0:
		shake_timer -= delta
		var offset = Vector2(randf_range(-shake_magnitude, shake_magnitude), randf_range(-shake_magnitude, shake_magnitude))
		position = original_position + offset
	else:
		position = original_position
		
func shake(duration: float, magnitude: float) -> void:
	shake_duration = duration
	shake_magnitude = magnitude
	shake_timer = shake_duration
