summaryrefslogtreecommitdiff
path: root/Scripts
diff options
context:
space:
mode:
Diffstat (limited to 'Scripts')
-rw-r--r--Scripts/GameLoop.gd25
-rw-r--r--Scripts/GlobalVariables.gd1
-rw-r--r--Scripts/NumberNode.gd9
-rw-r--r--Scripts/Tutorial.gd31
4 files changed, 65 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()
diff --git a/Scripts/GlobalVariables.gd b/Scripts/GlobalVariables.gd
index fd7ce6c..12fb6b1 100644
--- a/Scripts/GlobalVariables.gd
+++ b/Scripts/GlobalVariables.gd
@@ -8,3 +8,4 @@ var is_snapping : bool = false
var player : Player
var ai : AI
var gameloop : GameLoop
+var tutorial_played : bool = false
diff --git a/Scripts/NumberNode.gd b/Scripts/NumberNode.gd
index b81481a..5fc4742 100644
--- a/Scripts/NumberNode.gd
+++ b/Scripts/NumberNode.gd
@@ -44,6 +44,8 @@ func _physics_process(_delta):
shadow_sprite.scale = sprite.scale
func join_from(node : NumberNode):
+ var prev_value = node.value
+
node.value += self.value
var modifier_label = node.get_node_or_null("ModifierLabel")
@@ -63,6 +65,13 @@ func join_from(node : NumberNode):
node.target_pos = self.position
node.update_visuals()
+
+ if node.value >= prev_value:
+ print("YYY")
+ node.get_node("Score").playing = true
+ else:
+ print("NNOOOOOO")
+ node.get_node("Ouch").playing = true
queue_free()
diff --git a/Scripts/Tutorial.gd b/Scripts/Tutorial.gd
new file mode 100644
index 0000000..91236eb
--- /dev/null
+++ b/Scripts/Tutorial.gd
@@ -0,0 +1,31 @@
+extends Node
+class_name Tutorial
+## OH NO 1 HOUR LEFT
+
+@export var step_controls : Array[Control]
+@export var current_step : int = 0
+
+var tutorial_started = false
+
+func _ready():
+ if !GlobalVariables.tutorial_played:
+ start_tutorial()
+
+func _input(_event):
+ if Input.is_action_just_pressed("space") && tutorial_started:
+ next_step()
+
+func start_tutorial():
+ tutorial_started = true
+ step_controls[0].visible = true
+ current_step = 0
+
+func next_step():
+ if current_step + 1 < step_controls.size():
+ step_controls[current_step].visible = false
+ step_controls[current_step + 1].visible = true
+ current_step += 1
+ else:
+ step_controls[current_step].visible = false
+ tutorial_started = false
+ GlobalVariables.tutorial_played = true