summaryrefslogtreecommitdiff
path: root/Scripts
diff options
context:
space:
mode:
Diffstat (limited to 'Scripts')
-rw-r--r--Scripts/AI.gd4
-rw-r--r--Scripts/GameLoop.gd18
-rw-r--r--Scripts/Generator.gd2
-rw-r--r--Scripts/NumberNode.gd14
-rw-r--r--Scripts/Player.gd11
5 files changed, 36 insertions, 13 deletions
diff --git a/Scripts/AI.gd b/Scripts/AI.gd
index 1428c06..886bb30 100644
--- a/Scripts/AI.gd
+++ b/Scripts/AI.gd
@@ -11,6 +11,9 @@ class_name AI
func _ready():
GlobalVariables.ai = self
+func _process(_delta):
+ shape_cast_original.shape.radius = max_distance
+
func step(alternative : bool = false):
var shape_cast : ShapeCast2D
@@ -37,5 +40,6 @@ func step(alternative : bool = false):
else:
if !alternative:
step(true)
+ print("i have skill issue")
else:
print("i am softlocked!")
diff --git a/Scripts/GameLoop.gd b/Scripts/GameLoop.gd
index e5cf08e..6b71faf 100644
--- a/Scripts/GameLoop.gd
+++ b/Scripts/GameLoop.gd
@@ -3,7 +3,9 @@ class_name GameLoop
@export var turns : int
@export var label : Label
+@export var turn_label : Label
@export_file var level : String
+@export var can_play : bool = true
var current_turns : int = 0
var prev_turn : int = -1
@@ -14,13 +16,19 @@ func _ready():
current_turns = 0
func _process(_delta):
- if current_turns >= turns:
- label.text = "FINISHED!"
-
if prev_turn != current_turns:
prev_turn = current_turns
- label.text = "Turns Left: " + str(turns - current_turns)
- if current_turns != 0: GlobalVariables.ai.step()
+ label.text = str(turns - current_turns)
+ if current_turns != 0:
+ 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)
+
+func _on_between_player_and_ai_timeout():
+ GlobalVariables.ai.step()
+ can_play = true
+ if current_turns < turns: turn_label.text = "your turn!"
+ else: turn_label.text = ""
diff --git a/Scripts/Generator.gd b/Scripts/Generator.gd
index 834e07b..78ffa2f 100644
--- a/Scripts/Generator.gd
+++ b/Scripts/Generator.gd
@@ -36,7 +36,7 @@ func generate():
if is_big:
new.position = Vector2(randf_range(400, 900), randf_range(200, 400)) # disgusting hardcoded values, or not really?
else:
- new.position = Vector2(randf_range(30, 1250), randf_range(30, 690))
+ new.position = Vector2(randf_range(30, 1250), randf_range(90, 690))
get_node(GlobalVariables.NODE).add_child(new)
diff --git a/Scripts/NumberNode.gd b/Scripts/NumberNode.gd
index b566781..016a83c 100644
--- a/Scripts/NumberNode.gd
+++ b/Scripts/NumberNode.gd
@@ -19,17 +19,27 @@ enum Operations {
@export_subgroup("Visual Nodes")
@export var label : Label
@export var sprite : Sprite2D
+@export var shadow_sprite : Sprite2D
@export var sprite_modifier : Sprite2D
@export_subgroup("Visual Values")
@export var color : Color = Color.BLACK
@export var min_scale : float
@export var max_scale : float
+@export var target_pos : Vector2
+
+var size : float = 1
func _ready():
+ size = sprite.scale.x
+ target_pos = position
update_visuals()
func _process(_delta):
- pass
+ sprite.scale = Vector2(size, size)
+ shadow_sprite.scale = sprite.scale
+
+func _physics_process(_delta):
+ position = position.lerp(target_pos, 0.2)
func join_from(node : NumberNode):
node.value += self.value
@@ -49,7 +59,7 @@ func join_from(node : NumberNode):
node.value = roundi(float(node.value) / float(self.modifier))
if modifier_label: modifier_label.pop("/ " + str(self.modifier))
- node.position = self.position
+ node.target_pos = self.position
node.update_visuals()
queue_free()
diff --git a/Scripts/Player.gd b/Scripts/Player.gd
index f3b9667..a7b398a 100644
--- a/Scripts/Player.gd
+++ b/Scripts/Player.gd
@@ -13,7 +13,8 @@ func _ready():
gameloop = GlobalVariables.gameloop
func _input(event):
- if GlobalVariables.is_snapping:
+ if GlobalVariables.is_snapping && gameloop.can_play && gameloop.current_turns < gameloop.turns:
+ line.visible = true
var target_pos = (line.global_position - get_viewport().get_mouse_position())
var dist = sqrt(abs(target_pos.x) * abs(target_pos.x) + abs(target_pos.y) * abs(target_pos.y))
@@ -27,17 +28,17 @@ func _input(event):
if event is InputEventMouseButton && !event.pressed:
GlobalVariables.is_snapping = false
+ line.points[1] = Vector2.ZERO
+ line.visible = false
- if target != null && gameloop.current_turns < gameloop.turns:
+ if target != null && gameloop.can_play && gameloop.current_turns < gameloop.turns:
target.join_from($"..")
gameloop.current_turns += 1
-
- line.points[1] = Vector2.ZERO
if target != null:
line.rotation = 0
line.points[1] = -(line.global_position - target.global_position)
func _on_player_area_2d_input_event(_viewport : Node, event : InputEvent, _shape_idx : int):
- if event is InputEventMouseButton && event.pressed:
+ if event is InputEventMouseButton && event.pressed && gameloop.can_play && gameloop.current_turns < gameloop.turns:
GlobalVariables.is_snapping = true