Exemple #1
0
 public void placeBlock(bool[,] listToPlaceBlock, Tetromino blockToPlace)
 {
     for (int i = 0; i < blockToPlace.Pieces.GetLength(0) - blockToPlace.emptyRowsFromBottom(); i++)
     {
         for (int c = 0; c < blockToPlace.Pieces.GetLength(1) - blockToPlace.emptyColumnsFromRight(); c++)
         {
             if (blockToPlace.Pieces[i, c])
             {
                 listToPlaceBlock[blockToPlace.X + c, blockToPlace.Y + i] = blockToPlace.Pieces[i, c];
             }
         }
     }
 }
Exemple #2
0
        public int[,] findTetroPositionInField(Tetromino tetro) //Checks from top left of Tetro Position to bottom right of playfield for true statements and logs it as such
        {                                                       /*Might not work when the block has fallen (so we might need to change it so it only finds the actual tetromino piece and not others)
                                                                 * possibly through comparing the Tetrominos pieces array with the blocks from the x and y and get the positions based on that*/
         //order of each block positions stored is top left to bottom right (from its x and y)


            int[,] TetrominoPiecePositions = new int[4, 2];
            int pieceCounter = 0;


            for (int i = currentTetromino.X; i < currentTetromino.X + (4 - currentTetromino.emptyColumnsFromRight()); i++)
            {
                for (int c = currentTetromino.Y; c < currentTetromino.Y + (4 - currentTetromino.emptyRowsFromBottom()); c++)
                {
                    if (playField[i, c] && currentTetromino.Pieces[c - currentTetromino.Y, i - currentTetromino.X])
                    {
                        TetrominoPiecePositions[pieceCounter, 0] = i;
                        TetrominoPiecePositions[pieceCounter, 1] = c;
                        pieceCounter++;
                    }
                }
            }
            return(TetrominoPiecePositions);
        }