I'm a beginner trying to make a puzzle-type inventory game. I want to make a grid that contains spots I can drag items to, but I'm having trouble with a few things: 1. How do I create a grid that I can fill with drag-and-drop items? 2. How do I make items take up a certain number of grid spaces i.e. 2 spaces vertically?

Right now, I'm using some code from a tutorial for draggable items and dropzones:

Draggable Items:

extends Node2D

var selected = false
var rest_point
var rest_nodes = []
 
func _ready() -> void:
	rest_nodes = get_tree().get_nodes_in_group("zone")
	rest_point = rest_nodes[0].global_position
	rest_nodes[0].select()


func _on_Area2D_input_event(viewport: Node, event: InputEvent, shape_idx: int) -> void:
	if Input.is_action_just_pressed("Left Click"):
		selected = true
	


func _physics_process(delta: float) -> void:
	if selected:
		global_position = lerp(global_position, get_global_mouse_position(), 35 * delta)
		look_at(get_global_mouse_position())
	else:
		global_position = lerp(global_position, rest_point, 10 * delta)
		rotation = lerp_angle(rotation, 0, 10 * delta)


func _input(event):
	if event is InputEventMouseButton:
		if event.button_index == BUTTON_LEFT and not event.pressed:
			selected = false
			var shortest_distance = 200
			for child in rest_nodes:
				var distance = global_position.distance_to(child.global_position)
				if distance < shortest_distance:
					child.select()
					rest_point = child.global_position
					shortest_distance = distance

DropZones:

extends Position2D


func _draw():
	draw_circle(Vector2.ZERO, 75, Color.blanchedalmond)
	

func select():
	for child in get_tree().get_nodes_in_group("zone"):
		child.deselect()
	modulate = Color.webmaroon
	

func deselect():
	modulate = Color.whitesmoke

Any help with conceptualizing/coding this would be appreciated! Thanks!!

The code in this post had been formatted by a moderator.

2 years later