diff --git a/grid.gd b/grid.gd index 0a56181..c1b15b0 100644 --- a/grid.gd +++ b/grid.gd @@ -21,10 +21,14 @@ func _ready(): var token_node = token.instantiate() add_child(token_node) token_node.position = Vector2(offset*column, offset*row) + token_node.set_type(randi_range(0,3 )) token_node.set_debug_label(str(row) + "," + str(column)) grid[row].append(token_node) - calculate_token_groups() + +func _process(_delta: float) -> void: + if Input.is_action_just_pressed("activate"): + calculate_token_groups() func populate_grid(): pass @@ -54,14 +58,20 @@ func calculate_token_groups(): visited_nodes.append(current_coord) var adjacent_token_coords = [ - [row - 1, col], - [row, col + 1], - [row + 1, col], - [row, col - 1] + [current_coord[0] - 1, current_coord[1]], + [current_coord[0], current_coord[1] + 1], + [current_coord[0] + 1, current_coord[1]], + [current_coord[0], current_coord[1] - 1] ] var valid_coords = adjacent_token_coords.filter( - func(coord_pair): return coord_pair[0] >= 0 and coord_pair[0] < rows and coord_pair[1] >= 0 and coord_pair[1] < cols + func(coord_pair): + return ( + coord_pair[0] >= 0 and + coord_pair[0] < rows and + coord_pair[1] >= 0 and + coord_pair[1] < cols + ) ) for coord in valid_coords: diff --git a/project.godot b/project.godot index ddbfeaf..c94c8ba 100644 --- a/project.godot +++ b/project.godot @@ -14,3 +14,16 @@ config/name="combo-car" run/main_scene="uid://bai2mcthexgm5" config/features=PackedStringArray("4.4", "GL Compatibility") config/icon="res://icon.svg" + +[input] + +activate={ +"deadzone": 0.2, +"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":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null) +] +} + +[rendering] + +renderer/rendering_method="gl_compatibility" +renderer/rendering_method.mobile="gl_compatibility" diff --git a/token.gd b/token.gd index 11507a5..fdcf4b7 100644 --- a/token.gd +++ b/token.gd @@ -10,8 +10,10 @@ var debug_label: Label func _ready(): color_polygon = $Color debug_label = $"Debug Label" - type = randi_range(0, 3) as token_type - match type: + +func set_type(type: token_type): + self.type = type + match self.type: token_type.TYPE_1: color_polygon.color = Color.RED token_type.TYPE_2: