hide missing piece
This commit is contained in:
		
							parent
							
								
									8a987c0b63
								
							
						
					
					
						commit
						abaa1f0991
					
				
					 1 changed files with 13 additions and 5 deletions
				
			
		|  | @ -8,19 +8,27 @@ export var width: int = 512 | ||||||
| export var height: int = 512 | export var height: int = 512 | ||||||
| 
 | 
 | ||||||
| var pieces: Array = [] | var pieces: Array = [] | ||||||
|  | var missing_piece: Vector2 | ||||||
| 
 | 
 | ||||||
| func _draw() -> void: | func _draw() -> void: | ||||||
| 	draw_rect(Rect2(0, 0, width, height), Color.blue) | 	draw_rect(Rect2(0, 0, width, height), Color.blue) | ||||||
| 	 | 	 | ||||||
| func _ready() -> void: | func _ready() -> void: | ||||||
| 	for r in range(rows): | 	for c in range(columns): | ||||||
| 		for c in range(columns): | 		var pieces_row: Array = [] | ||||||
| 			if r == rows - 1 && c == columns - 1: | 		for r in range(rows): | ||||||
| 				continue | 			 | ||||||
| 			var piece = Piece.new() | 			var piece = Piece.new() | ||||||
| 			var padding_w = (width - (piece.size * columns)) / (columns + 1) | 			var padding_w = (width - (piece.size * columns)) / (columns + 1) | ||||||
| 			var padding_h = (height - (piece.size * rows)) / (rows + 1) | 			var padding_h = (height - (piece.size * rows)) / (rows + 1) | ||||||
| 			var initial_position = Vector2(padding_w + c * (piece.size + padding_w), padding_h + r * (piece.size + padding_h)) | 			var initial_position = Vector2(padding_w + c * (piece.size + padding_w), padding_h + r * (piece.size + padding_h)) | ||||||
| 			piece.translate(initial_position) | 			piece.translate(initial_position) | ||||||
|  | 			 | ||||||
|  | 			if r == rows - 1 && c == columns - 1: | ||||||
|  | 				piece.visible = false | ||||||
|  | 				missing_piece.x = c | ||||||
|  | 				missing_piece.y = r | ||||||
|  | 			 | ||||||
| 			add_child(piece) | 			add_child(piece) | ||||||
| 			pieces.append(piece) | 			pieces_row.append(piece) | ||||||
|  | 		pieces.append(pieces_row) | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue