taqin/game/src/Piece.gd

22 lines
640 B
GDScript3
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
2019-11-25 01:16:06 +01:00
var number: int = 0
2020-02-12 14:00:47 +01:00
var taquin_position = Vector2.ZERO
var taquin_index = Vector2.ZERO
2019-11-27 22:25:07 +01:00
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)
2019-11-27 00:50:35 +01:00
$ColorRect/Label.text = str(number)
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