diff options
author | altaf-creator <dev@altafcreator.com> | 2024-04-15 06:48:35 +0700 |
---|---|---|
committer | altaf-creator <dev@altafcreator.com> | 2024-04-15 06:48:35 +0700 |
commit | a0c5063fbc0f7f4f1205a58f764995243d800184 (patch) | |
tree | 595dd136155fb3fb2fee3b251b6dcbc91dbb3469 /Scripts/GameLoop.gd | |
parent | e730e2188eda08bf84fea7335dc2c0f3b5551509 (diff) |
sfx, tutorial, polish
Diffstat (limited to 'Scripts/GameLoop.gd')
-rw-r--r-- | Scripts/GameLoop.gd | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/Scripts/GameLoop.gd b/Scripts/GameLoop.gd index 6b71faf..6446fbd 100644 --- a/Scripts/GameLoop.gd +++ b/Scripts/GameLoop.gd @@ -6,6 +6,9 @@ class_name GameLoop @export var turn_label : Label @export_file var level : String @export var can_play : bool = true +@export var win_control : Control +@export var anim : AnimationPlayer +@export var anim_label : Label var current_turns : int = 0 var prev_turn : int = -1 @@ -23,7 +26,7 @@ func _process(_delta): can_play = false turn_label.text = "ai's turn..." $"BetweenPlayerAndAI".start() - + if Input.is_action_just_pressed("reset"): get_tree().change_scene_to_file(level) @@ -32,3 +35,23 @@ func _on_between_player_and_ai_timeout(): can_play = true if current_turns < turns: turn_label.text = "your turn!" else: turn_label.text = "" + + if current_turns >= turns: + win_control.visible = true + anim.play("win") + if GlobalVariables.player.get_node("..").value > GlobalVariables.ai.get_node("..").value: + anim_label.text = "YOU won!" + elif GlobalVariables.player.get_node("..").value < GlobalVariables.ai.get_node("..").value: + anim_label.text = "AI won!" + else: + anim_label.text = "It's a TIE!" + + $"AudioDelay".start() + +func _on_audio_delay_timeout(): + if GlobalVariables.player.get_node("..").value > GlobalVariables.ai.get_node("..").value: + win_control.get_node("Win").play() + elif GlobalVariables.player.get_node("..").value < GlobalVariables.ai.get_node("..").value: + win_control.get_node("Lose").play() + else: + win_control.get_node("Win").play() |