refactor with ColorRect

This commit is contained in:
Fabien Freling 2019-11-27 00:50:35 +01:00
parent d98ad5fd23
commit 8a720717e4
4 changed files with 73 additions and 11 deletions

View file

@ -19,8 +19,8 @@ var pieces: Array = []
var missing_piece: Vector2
var rng = RandomNumberGenerator.new()
func _draw() -> void:
draw_rect(Rect2(0, 0, width, height), Color.blue)
#func _draw() -> void:
# draw_rect(Rect2(0, 0, width, height), Color.blue)
func position_for_index(index: Vector2, size: int) -> Vector2:
var padding_w = (width - (size * columns)) / (columns + 1)
@ -29,6 +29,9 @@ func position_for_index(index: Vector2, size: int) -> Vector2:
func _ready() -> void:
$ColorRect.rect_size.x = width
$ColorRect.rect_size.y = height
rng.randomize()
var piece_size: int = compute_piece_size()
@ -46,7 +49,7 @@ func _ready() -> void:
missing_piece.x = c
missing_piece.y = r
add_child(piece)
$ColorRect.add_child(piece)
pieces_row.append(piece)
pieces.append(pieces_row)