Exemplo n.º 1
0
        /// <summary>
        /// Rotates the tile counter clockwise
        /// </summary>
        /// <returns>Rotated tile</returns>
        public BoardBlock RotateClockwise()
        {
            int[,] newMatrix = new int[Grid.GetLength(1), Grid.GetLength(0)];
            int newColumn, newRow = 0;

            for (int oldColumn = 0; oldColumn <= Grid.GetLength(1) - 1; oldColumn++)
            {
                newColumn = 0;
                for (int oldRow = Grid.GetLength(0) - 1; oldRow >= 0; oldRow--)
                {
                    newMatrix[newRow, newColumn] = Grid[oldRow, oldColumn];
                    newColumn++;
                }
                newRow++;
            }
            BoardBlock block = new BoardBlock(newMatrix, new Point(Position.X, Position.Y));

            return(block);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Rotates the tile counter clockwise
        /// </summary>
        /// <returns>Rotated tile</returns>
        public BoardBlock RotateCounterClockwise()
        {
            int[,] newMatrix = new int[Grid.GetLength(1), this.Grid.GetLength(0)];
            int newColumn, newRow = 0;

            for (int oldColumn = Grid.GetLength(1) - 1; oldColumn >= 0; oldColumn--)
            {
                newColumn = 0;
                for (int oldRow = 0; oldRow < Grid.GetLength(0); oldRow++)
                {
                    newMatrix[newRow, newColumn] = Grid[oldRow, oldColumn];
                    newColumn++;
                }
                newRow++;
            }
            BoardBlock block = new BoardBlock(newMatrix, Position);

            return(block);
        }