Example #1
0
 public static void Draw(ScreenRegion region)
 {
     region.rect.RefreshSides();
     rect = new SmallRect()
     {
         Left = (short)region.rect.left, Top = (short)region.rect.top, Right = (short)(region.rect.right + 1), Bottom = (short)(region.rect.bottom + 1)
     };
     WriteConsoleOutput(handle, ConvertToCharInfo(region), new InteropCoord(region.rect.size), new InteropCoord(0, 0), ref rect);
 }
Example #2
0
        private static CharInfo[] ConvertToCharInfo(ScreenRegion region)
        {
            CharInfo[] convertedContent = new CharInfo[region.rect.size.x * region.rect.size.y];

            for (int y = 0; y < region.rect.size.y; y++)
            {
                for (int x = 0; x < region.rect.size.x; x++)
                {
                    convertedContent[(y * region.rect.size.x) + x].Attributes          = (byte)((byte)region.grid[y][x].foreground | ((byte)region.grid[y][x].background << 4));
                    convertedContent[(y * region.rect.size.x) + x].CharUnion.AsciiChar = region.grid[y][x].texture;
                }
            }

            return(convertedContent);
        }
Example #3
0
 public static void Init(Coord windowSize, Coord gameSize, int pixelWidth)
 {
     Window.Init(windowSize);
     Game.pixelWidth = pixelWidth;
     background      = new GamePixel(pixelWidth, 0, 0);
     if (gameSize.x <= 0 | gameSize.y <= 0)
     {
         gameSize = new Coord(Console.WindowWidth / pixelWidth, Console.WindowHeight);
     }
     size       = gameSize;
     gameRegion = new ScreenRegion(new Coord(0, 0));
     InitGrid();
     InitViewport();
     edgeBumper     = 2;
     entities       = new List <Entity>();
     excludedLayers = new List <int>();
     gameTicker     = new Ticker(0.1f);
     viewportTicker = gameTicker;
     paused         = false;
 }
Example #4
0
        public static void Init(Coord size)
        {
            if (size.x >= 32 & size.y >= 16)
            {
                Console.SetWindowSize(size.x, size.y);
                Console.SetBufferSize(size.x, size.y);
                Console.SetWindowSize(size.x, size.y);
            }
            else
            {
                Interop.FullscreenWindow();
            }

            Interop.DisableResizing();
            Interop.SetConsoleHandle();

            content       = new ScreenRegion(new Coord(Console.WindowWidth, Console.WindowHeight));
            screenRegions = new List <ScreenRegion>()
            {
                new ScreenRegion(new Coord(0, 0))
            };
        }
Example #5
0
        public static void Update()
        {
            CheckForSizeChange();
            content.Clear();

            for (int s = 0; s < screenRegions.Count(); s++)
            {
                ScreenRegion region = screenRegions[s];

                if (region.active)
                {
                    for (int y = 0; y < region.rect.size.y; y++)
                    {
                        for (int x = 0; x < region.rect.size.x; x++)
                        {
                            content.grid[region.rect.position.y + y][region.rect.position.x + x] = region.grid[y][x];
                        }
                    }
                }
            }

            Interop.Draw(content);
        }