extends Camera2D

#var shake_time = 0 setget _set_shake_time, _get_shake_time
var amplitude = 1
var shake = false setget _enable_shake, _get_shake_state
var zoom = Vector2(1,1)

func _process(delta):
	if shake:
		set_offset(Vector2(rand_range(-amplitude, amplitude), rand_range(-amplitude, amplitude)))
	else:
		set_offset(Vector2(0,0))

func _enable_shake(new_state):
	if shake != new_state:
		if new_state:
			set_process(new_state)
		shake = new_state

func _get_shake_state():
	return shake
	
	

#func _get_shake_time():
#	return shake_time
#	
#func _set_shake_time(t):
#	if shake_time < t:
#		set_process(true)
#	if shake_time == 0:
#		set_process(false)
#	shake_time = t