コード例 #1
0
        /// <summary>
        /// Draws a map on the screen
        /// </summary>
        /// <param name="offsetX">Horizontal offset</param>
        /// <param name="offsetY">Vertical offset</param>
        /// <param name="map">Map to be drawn</param>
        /// <param name="function">Function that merges the blocks</param>
        public void DrawMap(
            int             offsetX,
            int             offsetY,
            ConsoleBlockMap map,
            Func<
                int,
                int,
                int,
                ConsoleBlock,
                int,
                int,
                int,
                ConsoleBlock,
                ConsoleBlock
            > function = null
        )
        {
            if (function == null)
                function = Utils.BlockJustReplaceIfNotEmpty;

            _Map.Merge(offsetX, offsetY, map, function);
        }
コード例 #2
0
        /// <summary>
        /// Creates a new console screen manager
        /// </summary>
        /// <param name="width">Screen width</param>
        /// <param name="height">Screen height</param>
        public ConsoleScreen(int width, int height)
        {
            // Increases the height to avoid annoying screen scrollings
            // TODO: figure out a way to avoid screen scrolling without having to do this
            ++height;

            // Sets the screen size
            Console.SetWindowSize(width, height);
            Console.SetBufferSize(width, height);
            // Hides the ugly cursor
            Console.CursorVisible = false;

            // Restores the given height
            --height;

            // Creates a map for drawing
            _Map     = new ConsoleBlockMap(width, height);
            _LastMap = _Map.Clone;

            // Prints it entirely on the console
            Show(false);
        }
コード例 #3
0
 /// <summary>
 /// Clears the screen with a given background
 /// </summary>
 /// <param name="background">Background</param>
 public void Clear(ConsoleBlockMap background)
 {
     _Map.CopyFrom(background);
 }