diff --git a/scenes/game.tscn b/scenes/game.tscn index 729a038..a360818 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -45,7 +45,7 @@ position = Vector2(629, 37) [node name="CharacterBody2D" type="CharacterBody2D" parent="."] position = Vector2(524, 393) script = ExtResource("2_uc4yi") -PUSH_FORCE = 50 +PUSH_FORCE = 100 metadata/_edit_group_ = true [node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D"] diff --git a/scripts/gameController.gd b/scripts/gameController.gd index 9f7fcd9..4bd1cad 100644 --- a/scripts/gameController.gd +++ b/scripts/gameController.gd @@ -1,17 +1,38 @@ extends Node2D +var boxTotal = 4 +var timer:= Timer.new() +@export var secondCount= 15 # Called when the node enters the scene tree for the first time. func _ready() -> void: - pass # Replace with function body. + add_child(timer) + timer.wait_time = 1 + timer.one_shot = false + timer.connect("timeout", secondCounter) + timer.start() +func secondCounter(): + print("time left: ", secondCount) + secondCount -=1 + if secondCount <= 0: + print("A loser is you") + get_tree().reload_current_scene() + # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: pass func _on_trigger(effect: Variant, body) -> void: print("they were triggered!") - if body is RigidBody2D: + if body is RigidBody2D: print("crate spotted") + boxTotal -= 1 body.queue_free() + if boxTotal <=0: + print("A winner is you") + get_tree().reload_current_scene() + + +