summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Levels/IncreaseSize.gd16
-rw-r--r--Levels/game.tscn46
-rw-r--r--Scripts/AI.gd6
-rw-r--r--Scripts/GameLoop.gd8
-rw-r--r--project.godot8
5 files changed, 79 insertions, 5 deletions
diff --git a/Levels/IncreaseSize.gd b/Levels/IncreaseSize.gd
new file mode 100644
index 0000000..ed761ce
--- /dev/null
+++ b/Levels/IncreaseSize.gd
@@ -0,0 +1,16 @@
+extends Node
+class_name IncreaseSize
+## Increase size as [member NumberNode.value] increases.
+
+@export var me : NumberNode
+@export var player : Node # Should be [Player] or [AI]
+
+@export var max_value : int
+@export var min_size : float
+@export var max_size : float
+@export var min_range : float
+@export var max_range : float
+
+func _process(_delta):
+ var scale = min_size + ((max_size - min_size) * ((max_value - (max_value - clampf(me.value, 0, max_value))) / max_value))
+ me.scale = Vector2(scale, scale)
diff --git a/Levels/game.tscn b/Levels/game.tscn
index 248bdab..c64175f 100644
--- a/Levels/game.tscn
+++ b/Levels/game.tscn
@@ -1,9 +1,10 @@
-[gd_scene load_steps=10 format=3 uid="uid://rd1m2fu22g1s"]
+[gd_scene load_steps=11 format=3 uid="uid://rd1m2fu22g1s"]
[ext_resource type="PackedScene" uid="uid://ccvoi0qmvlxmj" path="res://Reusable Scenes/number_node.tscn" id="1_j877y"]
[ext_resource type="Script" path="res://Scripts/Generator.gd" id="1_uaslf"]
[ext_resource type="Script" path="res://Scripts/Player.gd" id="3_j3fp5"]
[ext_resource type="Script" path="res://Scripts/GameLoop.gd" id="3_u7xnc"]
+[ext_resource type="Script" path="res://Levels/IncreaseSize.gd" id="5_8xpc8"]
[ext_resource type="Script" path="res://Scripts/ModifierLabel.gd" id="5_lj1b3"]
[ext_resource type="Script" path="res://Scripts/AI.gd" id="6_ncui2"]
@@ -21,13 +22,14 @@ radius = 120.0
[node name="Generator" type="Node" parent="."]
script = ExtResource("1_uaslf")
numbernode = ExtResource("1_j877y")
-min_nodes = 50
+min_nodes = 70
max_nodes = 100
[node name="GameLoop" type="Node" parent="." node_paths=PackedStringArray("label")]
script = ExtResource("3_u7xnc")
-turns = 100
+turns = 10
label = NodePath("../Label")
+level = "res://Levels/game.tscn"
[node name="Player" parent="." instance=ExtResource("1_j877y")]
z_index = 4096
@@ -40,6 +42,14 @@ script = ExtResource("3_j3fp5")
max_distance = 160.0
line = NodePath("../Line2D")
+[node name="IncreaseSize" type="Node" parent="Player" node_paths=PackedStringArray("me", "player")]
+script = ExtResource("5_8xpc8")
+me = NodePath("..")
+player = NodePath("../Player")
+max_value = 100
+min_size = 1.0
+max_size = 2.0
+
[node name="Line2D" type="Line2D" parent="Player"]
z_index = -1
points = PackedVector2Array(0, 0, 0, 0)
@@ -87,6 +97,14 @@ script = ExtResource("6_ncui2")
shape_cast_original = NodePath("../AIShapeCast2D")
shape_cast_skill_issue = NodePath("../ThisAIHasSkillIssue")
+[node name="IncreaseSize" type="Node" parent="AI" node_paths=PackedStringArray("me", "player")]
+script = ExtResource("5_8xpc8")
+me = NodePath("..")
+player = NodePath("../AI")
+max_value = 100
+min_size = 1.0
+max_size = 2.0
+
[node name="ThisAIHasSkillIssue" type="ShapeCast2D" parent="AI"]
modulate = Color(1, 0, 0, 1)
shape = SubResource("CircleShape2D_ml6nm")
@@ -99,6 +117,27 @@ shape = SubResource("CircleShape2D_4p6y7")
target_position = Vector2(0, 0)
collide_with_areas = true
+[node name="ModifierLabel" type="Label" parent="AI"]
+visible = false
+anchors_preset = 7
+anchor_left = 0.5
+anchor_top = 1.0
+anchor_right = 0.5
+anchor_bottom = 1.0
+offset_left = -31.0
+offset_top = -59.0
+offset_right = 31.0
+offset_bottom = -36.0
+grow_horizontal = 2
+grow_vertical = 0
+text = "+ X"
+horizontal_alignment = 1
+vertical_alignment = 1
+script = ExtResource("5_lj1b3")
+
+[node name="Timer" type="Timer" parent="AI/ModifierLabel"]
+wait_time = 2.0
+
[node name="NumberNode" parent="." instance=ExtResource("1_j877y")]
position = Vector2(95, 551)
@@ -112,3 +151,4 @@ text = "Turns Left: X"
[connection signal="input_event" from="Player/PlayerArea2D" to="Player/Player" method="_on_player_area_2d_input_event"]
[connection signal="timeout" from="Player/ModifierLabel/Timer" to="Player/ModifierLabel" method="_on_timer_timeout"]
+[connection signal="timeout" from="AI/ModifierLabel/Timer" to="AI/ModifierLabel" method="_on_timer_timeout"]
diff --git a/Scripts/AI.gd b/Scripts/AI.gd
index d5cbcbe..1428c06 100644
--- a/Scripts/AI.gd
+++ b/Scripts/AI.gd
@@ -2,6 +2,7 @@ extends Node
class_name AI
@export_group("Values")
+@export var max_distance : float
@export_group("Scenes")
@export var shape_cast_original : ShapeCast2D
@@ -34,4 +35,7 @@ func step(alternative : bool = false):
if nodes.size() > 0:
nodes[0].join_from($"..")
else:
- step(true)
+ if !alternative:
+ step(true)
+ else:
+ print("i am softlocked!")
diff --git a/Scripts/GameLoop.gd b/Scripts/GameLoop.gd
index 04cd370..e5cf08e 100644
--- a/Scripts/GameLoop.gd
+++ b/Scripts/GameLoop.gd
@@ -3,12 +3,15 @@ class_name GameLoop
@export var turns : int
@export var label : Label
+@export_file var level : String
+
var current_turns : int = 0
var prev_turn : int = -1
# Called when the node enters the scene tree for the first time.
func _ready():
GlobalVariables.gameloop = self
+ current_turns = 0
func _process(_delta):
if current_turns >= turns:
@@ -17,4 +20,7 @@ func _process(_delta):
if prev_turn != current_turns:
prev_turn = current_turns
label.text = "Turns Left: " + str(turns - current_turns)
- GlobalVariables.ai.step()
+ if current_turns != 0: GlobalVariables.ai.step()
+
+ if Input.is_action_just_pressed("reset"):
+ get_tree().change_scene_to_file(level)
diff --git a/project.godot b/project.godot
index 0971d0a..a2bea0b 100644
--- a/project.godot
+++ b/project.godot
@@ -26,6 +26,14 @@ window/size/viewport_height=720
window/size/mode=3
window/stretch/mode="canvas_items"
+[input]
+
+reset={
+"deadzone": 0.5,
+"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":82,"key_label":0,"unicode":114,"echo":false,"script":null)
+]
+}
+
[rendering]
renderer/rendering_method="gl_compatibility"