/* Calculates the amount of rows the tetromino must be moved up * to touch the top of the grid. */ private int CalculatePreviewRowOffset(Tetromino piece) { /* Startvalue of -1 as 0 is a valid row. */ int row = -1; /* Loop through the entire grid or until a block has been found. */ for (int i = 0; i < piece.Width && row == -1; i++) { for (int j = 0; j < piece.Width; j++) { if (piece.GetBlock(i, j)) { row = i; break; } } } return(-row); }