extends Node2D
class_name Piece
tool

export var size: int = 160

var number: int = 0
var taquin_position = Vector2(0, 0)
var piece_scale = Vector2(0.25, 0.25)

func _ready() -> void:
	$ColorRect.rect_size = Vector2(size, size)
	$ColorRect/Label.text = str(number)

	# We need a dedicated material to have separate uniform,
	# otherwise uniforms will be shared.
	var mat = $ColorRect.material.duplicate() as ShaderMaterial
	mat.set_shader_param("scale", Vector3(piece_scale.x, piece_scale.y, 1.0))
	mat.set_shader_param("offset", Vector3(taquin_position.x, taquin_position.y, 0.0))
	$ColorRect.material = mat
