diff --git a/game_window.tscn b/game_window.tscn index 69d9152..77a307e 100644 --- a/game_window.tscn +++ b/game_window.tscn @@ -7,6 +7,11 @@ [node name="Grid" type="Node2D" parent="."] position = Vector2(393, 224) script = ExtResource("1_mn5vm") -rows = 4 -cols = 4 offset = 60.0 + +[node name="Debug Label" type="Label" parent="Grid"] +offset_left = -245.0 +offset_top = -134.0 +offset_right = -16.0 +offset_bottom = -51.0 +autowrap_mode = 1 diff --git a/grid.gd b/grid.gd index 4a1455d..0a56181 100644 --- a/grid.gd +++ b/grid.gd @@ -8,15 +8,20 @@ extends Node2D var grid: Array[Array] var groups: Array +var debug_label: Label + var token = preload("res://token.tscn") func _ready(): + debug_label = $"Debug Label" + for row in rows: grid.append([]) for column in cols: var token_node = token.instantiate() add_child(token_node) - token_node.position = Vector2(offset*row, offset*column) + token_node.position = Vector2(offset*column, offset*row) + token_node.set_debug_label(str(row) + "," + str(column)) grid[row].append(token_node) calculate_token_groups() @@ -64,4 +69,4 @@ func calculate_token_groups(): group_queue.append(coord) groups.append(new_group) - print(groups) + debug_label.text = str(groups) diff --git a/project.godot b/project.godot index a0792a7..ddbfeaf 100644 --- a/project.godot +++ b/project.godot @@ -10,12 +10,7 @@ config_version=5 [application] -config/name="combo car" +config/name="combo-car" run/main_scene="uid://bai2mcthexgm5" config/features=PackedStringArray("4.4", "GL Compatibility") config/icon="res://icon.svg" - -[rendering] - -renderer/rendering_method="gl_compatibility" -renderer/rendering_method.mobile="gl_compatibility" diff --git a/token.gd b/token.gd index f0b2cbe..11507a5 100644 --- a/token.gd +++ b/token.gd @@ -5,9 +5,11 @@ enum token_type {TYPE_1, TYPE_2, TYPE_3, TYPE_4} var type: token_type = token_type.TYPE_1 var color_polygon +var debug_label: Label func _ready(): color_polygon = $Color + debug_label = $"Debug Label" type = randi_range(0, 3) as token_type match type: token_type.TYPE_1: @@ -18,3 +20,6 @@ func _ready(): color_polygon.color = Color.BLUE token_type.TYPE_4: color_polygon.color = Color.YELLOW + +func set_debug_label(text: String): + debug_label.text = text diff --git a/token.tscn b/token.tscn index c6d25d0..3c1c705 100644 --- a/token.tscn +++ b/token.tscn @@ -1,21 +1,35 @@ -[gd_scene load_steps=4 format=3 uid="uid://b50otusq306jl"] +[gd_scene load_steps=5 format=3 uid="uid://b50otusq306jl"] [ext_resource type="Script" uid="uid://cy18iue2caocn" path="res://token.gd" id="1_0ucay"] [ext_resource type="Texture2D" uid="uid://cqtw7t2uag6f8" path="res://icon.svg" id="1_bd72f"] +[sub_resource type="LabelSettings" id="LabelSettings_0ucay"] +outline_size = 2 +outline_color = Color(0, 0, 0, 1) + [sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_bd72f"] blend_mode = 1 [node name="Token" type="Node2D"] script = ExtResource("1_0ucay") +[node name="Debug Label" type="Label" parent="."] +z_index = 2 +offset_left = 6.0 +offset_top = 3.0 +offset_right = 39.0 +offset_bottom = 41.0 +text = "1,1" +label_settings = SubResource("LabelSettings_0ucay") + +[node name="Color" type="Polygon2D" parent="."] +z_index = 1 +material = SubResource("CanvasItemMaterial_bd72f") +position = Vector2(6, 6) +color = Color(0.84101, 0.000705212, 0.866408, 1) +polygon = PackedVector2Array(0, 0, 40, 0, 40, 40, 0, 40) + [node name="Sprite2D" type="Sprite2D" parent="."] scale = Vector2(0.4, 0.4) texture = ExtResource("1_bd72f") centered = false - -[node name="Color" type="Polygon2D" parent="."] -material = SubResource("CanvasItemMaterial_bd72f") -position = Vector2(6, 6) -color = Color(3.94672e-06, 0.565612, 0.802131, 1) -polygon = PackedVector2Array(0, 0, 40, 0, 40, 40, 0, 40)