diff options
author | Logan <logan@cflip.net> | 2022-10-01 19:00:19 -0600 |
---|---|---|
committer | Logan <logan@cflip.net> | 2022-10-01 19:00:19 -0600 |
commit | c976e1bfefad2d3c8f7608c3ef436879794f3b9d (patch) | |
tree | 98d8476d7619c3338e7a1f40a21cbc36f38c5ba4 | |
parent | 78a037a2652e2b7cc5f652f9c24119bbc8ec7df2 (diff) |
Add initial implementation of a timeout screen.
-rw-r--r-- | scenes/interface.tscn | 11 | ||||
-rw-r--r-- | scripts/global_variables.gd | 1 | ||||
-rw-r--r-- | scripts/hoop.gd | 2 | ||||
-rw-r--r-- | scripts/interface.gd | 16 |
4 files changed, 23 insertions, 7 deletions
diff --git a/scenes/interface.tscn b/scenes/interface.tscn index 8b37f8f..cba0c37 100644 --- a/scenes/interface.tscn +++ b/scenes/interface.tscn @@ -21,4 +21,15 @@ text = "Timer: " [node name="Timer" type="Timer" parent="."] +[node name="Control" type="Control" parent="."] +visible = false + +[node name="Label" type="Label" parent="Control"] +margin_top = 40.0 +margin_right = 214.0 +margin_bottom = 80.0 +text = "YOU LOSE. YOU WIN NOTHING. +GOOD DAY SIR!" +align = 1 + [connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"] diff --git a/scripts/global_variables.gd b/scripts/global_variables.gd index b570635..3f57f95 100644 --- a/scripts/global_variables.gd +++ b/scripts/global_variables.gd @@ -1,3 +1,4 @@ extends Node var score = 0 +var timer_zero = false diff --git a/scripts/hoop.gd b/scripts/hoop.gd index 61e2b99..c74afe6 100644 --- a/scripts/hoop.gd +++ b/scripts/hoop.gd @@ -6,7 +6,7 @@ var has_scored = false func _on_Area2D_body_exited(_body): # Prevent scoring multiple points with one basketball throw. - if !has_scored: + if !has_scored and !global_variables.timer_zero: global_variables.score += 1 has_scored = true emit_signal ("score") diff --git a/scripts/interface.gd b/scripts/interface.gd index 8aff53b..4a25ce3 100644 --- a/scripts/interface.gd +++ b/scripts/interface.gd @@ -8,14 +8,18 @@ func _ready(): $Timer.start() func _on_Hoop_score(): - if time_left > 0: - $ScoreLabel.text = "Score: " + str(global_variables.score) - time_left += 10 - update_timer() + $ScoreLabel.text = "Score: " + str(global_variables.score) + time_left += 10 + update_timer() func update_timer(): $TimerLabel.text = "Time: " + str(time_left) func _on_Timer_timeout(): - time_left -= 1 - update_timer() + if time_left > 0: + time_left -= 1 + update_timer() + else: + global_variables.timer_zero = true + $Timer.stop() + $Control.visible = true |