added debug labels
made row/column positions make sense
This commit is contained in:
@@ -7,6 +7,11 @@
|
|||||||
[node name="Grid" type="Node2D" parent="."]
|
[node name="Grid" type="Node2D" parent="."]
|
||||||
position = Vector2(393, 224)
|
position = Vector2(393, 224)
|
||||||
script = ExtResource("1_mn5vm")
|
script = ExtResource("1_mn5vm")
|
||||||
rows = 4
|
|
||||||
cols = 4
|
|
||||||
offset = 60.0
|
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
|
||||||
|
|||||||
9
grid.gd
9
grid.gd
@@ -8,15 +8,20 @@ extends Node2D
|
|||||||
var grid: Array[Array]
|
var grid: Array[Array]
|
||||||
var groups: Array
|
var groups: Array
|
||||||
|
|
||||||
|
var debug_label: Label
|
||||||
|
|
||||||
var token = preload("res://token.tscn")
|
var token = preload("res://token.tscn")
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
debug_label = $"Debug Label"
|
||||||
|
|
||||||
for row in rows:
|
for row in rows:
|
||||||
grid.append([])
|
grid.append([])
|
||||||
for column in cols:
|
for column in cols:
|
||||||
var token_node = token.instantiate()
|
var token_node = token.instantiate()
|
||||||
add_child(token_node)
|
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)
|
grid[row].append(token_node)
|
||||||
|
|
||||||
calculate_token_groups()
|
calculate_token_groups()
|
||||||
@@ -64,4 +69,4 @@ func calculate_token_groups():
|
|||||||
group_queue.append(coord)
|
group_queue.append(coord)
|
||||||
groups.append(new_group)
|
groups.append(new_group)
|
||||||
|
|
||||||
print(groups)
|
debug_label.text = str(groups)
|
||||||
|
|||||||
@@ -10,12 +10,7 @@ config_version=5
|
|||||||
|
|
||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="combo car"
|
config/name="combo-car"
|
||||||
run/main_scene="uid://bai2mcthexgm5"
|
run/main_scene="uid://bai2mcthexgm5"
|
||||||
config/features=PackedStringArray("4.4", "GL Compatibility")
|
config/features=PackedStringArray("4.4", "GL Compatibility")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
[rendering]
|
|
||||||
|
|
||||||
renderer/rendering_method="gl_compatibility"
|
|
||||||
renderer/rendering_method.mobile="gl_compatibility"
|
|
||||||
|
|||||||
5
token.gd
5
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 type: token_type = token_type.TYPE_1
|
||||||
|
|
||||||
var color_polygon
|
var color_polygon
|
||||||
|
var debug_label: Label
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
color_polygon = $Color
|
color_polygon = $Color
|
||||||
|
debug_label = $"Debug Label"
|
||||||
type = randi_range(0, 3) as token_type
|
type = randi_range(0, 3) as token_type
|
||||||
match type:
|
match type:
|
||||||
token_type.TYPE_1:
|
token_type.TYPE_1:
|
||||||
@@ -18,3 +20,6 @@ func _ready():
|
|||||||
color_polygon.color = Color.BLUE
|
color_polygon.color = Color.BLUE
|
||||||
token_type.TYPE_4:
|
token_type.TYPE_4:
|
||||||
color_polygon.color = Color.YELLOW
|
color_polygon.color = Color.YELLOW
|
||||||
|
|
||||||
|
func set_debug_label(text: String):
|
||||||
|
debug_label.text = text
|
||||||
|
|||||||
28
token.tscn
28
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="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"]
|
[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"]
|
[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_bd72f"]
|
||||||
blend_mode = 1
|
blend_mode = 1
|
||||||
|
|
||||||
[node name="Token" type="Node2D"]
|
[node name="Token" type="Node2D"]
|
||||||
script = ExtResource("1_0ucay")
|
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="."]
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
scale = Vector2(0.4, 0.4)
|
scale = Vector2(0.4, 0.4)
|
||||||
texture = ExtResource("1_bd72f")
|
texture = ExtResource("1_bd72f")
|
||||||
centered = false
|
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)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user