Example #1
0
        /// <summary>
        /// Takes a grid of 1s and 0s to create an orientation for a shape
        /// </summary>
        /// <param name="grid">Grid of 1s and 0s</param>
        /// <returns>Orientation object</returns>
        private static Orientation MakeOrientation(int[,] grid)
        {
            Orientation orientation = new Orientation();

            for (int r = 0; r < grid.GetLength(0); r++)
            {
                for (int c = 0; c < grid.GetLength(1); c++)
                {
                    if (grid[r, c] == 1)
                    {
                        orientation.AddPosition(new Position(c * Piece.SIZE, r * Piece.SIZE));
                    }
                }
            }
            return(orientation);
        }