Exemple #1
0
        // Image is combination of all object`s symbols
        public void EnqueueForRendering(IRenderable obj)
        {
            char[,] objImage = obj.GetImage();
            int imageRows = objImage.GetLength(0);
            int imageCols = objImage.GetLength(1);

            // Set the image in top-left corner
            FieldCoordinates objTopLeft = obj.GetTopLeft();

            // Move the image to his position
            int lastRow = Math.Min(objTopLeft.Row + imageRows, this.renderMatrixRows);
            int lastCol = Math.Min(objTopLeft.Col + imageCols, this.renderMatrixCols);

            for (int row = obj.GetTopLeft().Row; row < lastRow; row++)
            {
                for (int col = obj.GetTopLeft().Col; col < lastCol; col++)
                {
                    // Check if the object coordinates are in the fields
                    if (row >= 0 && row < renderMatrixRows &&
                        col >= 0 && col < renderMatrixCols)
                    {
                        renderMatrix[row, col] = objImage[row - obj.GetTopLeft().Row, col - obj.GetTopLeft().Col];
                    }
                }
            }
        }
        public void EnqueueForRendering(IRenderable obj)
        {
            char[,] objImage = obj.GetImage();

            int imageRows = objImage.GetLength(0);
            int imageCols = objImage.GetLength(1);

            MatrixCoords objTopLeft = obj.GetTopLeft();

            int lastRow = Math.Min(objTopLeft.Row + imageRows, this.renderContextMatrixRows);
            int lastCol = Math.Min(objTopLeft.Col + imageCols, this.renderContextMatrixCols);

            for (int row = obj.GetTopLeft().Row; row < lastRow; row++)
            {
                for (int col = obj.GetTopLeft().Col; col < lastCol; col++)
                {
                    if (row >= 0 && row < renderContextMatrixRows &&
                        col >= 0 && col < renderContextMatrixCols)
                    {
                        if ((objImage[row - obj.GetTopLeft().Row, col - obj.GetTopLeft().Col]) != ' ')
                        {
                            renderContextMatrix[row, col] = objImage[row - obj.GetTopLeft().Row, col - obj.GetTopLeft().Col];
                        }
                    }
                }
            }
        }
Exemple #3
0
        public void EnqueueForRendering(IRenderable unit)
        {
            char[,] unitImage = unit.GetImage();

            int imageRows = unitImage.GetLength(0);
            int imageCols = unitImage.GetLength(1);

            MatrixCoords unitTopLeft = unit.GetTopLeft();

            int lastRow = Math.Min(unitTopLeft.Row + imageRows, Rows);
            int lastCol = Math.Min(unitTopLeft.Col + imageCols, Cols);

            for (int row = unit.GetTopLeft().Row; row < lastRow; row++)
            {
                for (int col = unit.GetTopLeft().Col; col < lastCol; col++)
                {
                    if (row >= 0 && row < Rows && col >= 0 && col < Cols)
                    {
                        matrixToPrint[row, col] = unitImage[row - unit.GetTopLeft().Row, col - unit.GetTopLeft().Col];
                    }
                }
            }
        }
        public void EnqueueForRendering(IRenderable unit)
        {
            char[,] unitImage = unit.GetImage();

            int imageRows = unitImage.GetLength(0);
            int imageCols = unitImage.GetLength(1);

            MatrixCoords unitTopLeft = unit.GetTopLeft();

            int lastRow = Math.Min(unitTopLeft.Row + imageRows, Rows);
            int lastCol = Math.Min(unitTopLeft.Col + imageCols, Cols);

            for (int row = unit.GetTopLeft().Row; row < lastRow; row++)
            {
                for (int col = unit.GetTopLeft().Col; col < lastCol; col++)
                {
                    if (row >= 0 && row < Rows && col >= 0 && col < Cols)
                    {
                        matrixToPrint[row, col] = unitImage[row - unit.GetTopLeft().Row, col - unit.GetTopLeft().Col];
                    }
                }
            }
        }
Exemple #5
0
        public void EnqueueForRendering(IRenderable obj)
        {
            char[,] objImage = obj.GetImage();

            int imageRows = objImage.GetLength(0);
            int imageCols = objImage.GetLength(1);

            MatrixCoords objTopLeft = obj.GetTopLeft();

            int lastRow = Math.Min(objTopLeft.Row + imageRows, this.renderContextMatrixRows);
            int lastCol = Math.Min(objTopLeft.Col + imageCols, this.renderContextMatrixCols);

            for (int row = obj.GetTopLeft().Row; row < lastRow; row++)
            {
                for (int col = obj.GetTopLeft().Col; col < lastCol; col++)
                {
                    if (row >= 0 && row < renderContextMatrixRows &&
                        col >= 0 && col < renderContextMatrixCols)
                    {
                        renderContextMatrix[row, col] = objImage[row - obj.GetTopLeft().Row, col - obj.GetTopLeft().Col];
                    }
                }
            }
        }
        // this method adds an object for visualization.
        public void EnqueueForRendering(IRenderable obj)
        {
            char[,] objImage = obj.GetImage();

            int imageRows = objImage.GetLength(0);
            int imageCols = objImage.GetLength(1);

            MatrixCoords objTopLeft = obj.GetTopLeft(); // we extract the top left point from the object itself.

            int lastRow = Math.Min(objTopLeft.Row + imageRows, this.renderContextMatrixRows); // prevents us from getting out of the console.
            int lastCol = Math.Min(objTopLeft.Col + imageCols, this.renderContextMatrixCols); // prevents us from getting out of the console.

            for (int row = obj.GetTopLeft().Row; row < lastRow; row++)
            {
                for (int col = obj.GetTopLeft().Col; col < lastCol; col++)
                {
                    if (row >= 0 && row < renderContextMatrixRows &&
                            col >= 0 && col < renderContextMatrixCols)
                    {
                        renderContextMatrix[row, col] = objImage[row - obj.GetTopLeft().Row, col - obj.GetTopLeft().Col];
                    }
                }
            }
        }