From 90bdd350207c6d022f0a480b9e7a99ae890a98d2 Mon Sep 17 00:00:00 2001 From: "Kevin (O) Gorman" Date: Mon, 6 Jan 2025 20:51:49 -0500 Subject: [PATCH] add dramatic tension --- scenes/game.tscn | 2 +- scripts/gameController.gd | 25 +++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) 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() + + +