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];
                        }
                    }
                }
            }
        }
示例#2
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];
                    }
                }
            }
        }
示例#3
0
        public void EnqueuForRendering(IRenderable obj)
        {
            Vector objectPosition = obj.GetPosition();
            char   objectImage    = obj.GetImage();

            if (objectPosition.X >= 0 && objectPosition.X < gameWorld.GetLength(0) - 2 * offset &&
                objectPosition.Y >= 0 && objectPosition.Y < gameWorld.GetLength(1) - 2 * offset)
            {
                this.gameWorld[objectPosition.X + offset, objectPosition.Y + offset] = objectImage;
            }
        }
        /// <summary>
        /// Clears a rendered object from the console.
        /// </summary>
        /// <param name="obj">Object to be cleared.</param>
        public void Clear(IRenderable obj)
        {
            var objectImage = obj.GetImage();

            for (int row = 0; row < objectImage.GetLength(0); row++)
            {
                Console.SetCursorPosition(obj.TopLeftPosition.Col, obj.TopLeftPosition.Row + row);

                for (int col = 0; col < objectImage.GetLength(1); col++)
                {
                    Console.Write(" ");
                }
            }
        }
示例#5
0
        /// <summary>
        /// Enqueues an object to be rendered on the next scene of the game
        /// </summary>
        /// <param name="obj">The object to be rendered on the next scene</param>
        public void EnqueueForRendering(IRenderable obj)
        {
            char[,] image = obj.GetImage();

            for (int i = 0; i < image.GetLength(0); i++)
            {
                for (int j = 0; j < image.GetLength(1); j++)
                {
                    if (image[i, j] != ' ' &&
                        obj.X + j >= 0 && obj.X + j < this.image.GetLength(1) &&
                        obj.Y + i >= 0 && obj.Y + i < this.image.GetLength(0))
                    {
                        this.image[obj.Y + i, obj.X + j] = image[i, j];
                    }
                }
            }
        }
示例#6
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];
                    }
                }
            }
        }
示例#8
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];
                    }
                }
            }
        }
        /// <summary>
        /// Enqueues an object to be rendered on the next scene of the game
        /// </summary>
        /// <param name="obj">The object to be rendered on the next scene</param>
        public void EnqueueForRendering(IRenderable obj)
        {
            char[,] image = obj.GetImage();

            for (int i = 0; i < image.GetLength(0); i++)
            {
                for (int j = 0; j < image.GetLength(1); j++)
                {
                    if (image[i, j] != ' ' &&
                        obj.X + j >= 0 && obj.X + j < this.image.GetLength(1) &&
                        obj.Y + i >= 0 && obj.Y + i < this.image.GetLength(0))
                    {
                        this.image[obj.Y + i, obj.X + j] = image[i, j];
                    }
                }
            }
        }
示例#11
0
        public void EnqueueForRender(IRenderable obj)
        {
            char objImage = obj.GetImage();

            Vector2D position = obj.GetPosition() - this.origin;
            if (position.X >= 0 && position.X < renderContextMatrixCols &&
                position.Y >= 0 && position.Y < renderContextMatrixRows)
            {
                renderContextMatrix[position.Y, position.X] = objImage;
            }
        }