taqin/src/Piece.gd

27 lines
818 B
GDScript
Raw Normal View History

2020-01-12 18:51:07 +01:00
tool
2019-11-22 13:38:50 +01:00
extends Node2D
class_name Piece
2019-12-03 13:50:42 +01:00
export var size: int = 160
2020-02-13 13:38:07 +01:00
var order: int = 0
var taquin_position := Vector2.ZERO
var taquin_index := Vector2.ZERO
var piece_scale := Vector2(0.25, 0.25)
2019-11-25 01:16:06 +01:00
func _ready() -> void:
2019-12-03 13:50:42 +01:00
$ColorRect.rect_size = Vector2(size, size)
2020-02-13 13:38:07 +01:00
$ColorRect/Label.text = str(order)
2019-11-27 13:55:08 +01:00
2019-11-27 22:25:07 +01:00
# 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
2020-02-13 13:51:14 +01:00
func debug_print(name: String):
print("%s order: %s" % [name, order])
print("%s taquin index: %s" % [name, taquin_index])
print("%s taquin position: %s" % [name, position])