extends Node2D
var totalBoxes = 3
var timer:= Timer.new()
var countdown = 10
# Called when the node enters the scene tree for the first time.
func _ready():
	add_child(timer)
	timer.wait_time = 1
	timer.one_shot = false
	timer.connect("timeout", secondCounter)
	timer.start()

func secondCounter():
	print("one second")
	countdown -=1
	if countdown <=0:
		print("you lose")
		get_tree().reload_current_scene()


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
	pass

func _on_trigger_alert(body):
	totalBoxes -=1
	body.queue_free()
	if totalBoxes <=0:
		print("you won")
		get_tree().reload_current_scene()