Example #1
0
        public void DrawSprite(ConsoleSprite sprite, int x, int y, bool flipHorizontal = false)
        {
            var pixels = sprite.GetPixels();

            for (var y1 = 0; y1 < sprite.Height; ++y1)
            {
                for (var x1 = 0; x1 < sprite.Width; ++x1)
                {
                    var spi = flipHorizontal
                        ? y1 * sprite.Width + (sprite.Width - 1 - x1)
                        : y1 * sprite.Width + x1;

                    if (spi >= pixels.Length)
                    {
                        return;
                    }
                    if (pixels[spi] == null)
                    {
                        continue;
                    }
                    var color = pixels[spi].Value;
                    var i     = (y + y1) * Width + (x + x1);
                    if (i >= this.pixels.Length)
                    {
                        return;
                    }

                    this.pixels[i].Background = color;
                    this.pixels[i].Foreground = color;
                    //Buffer[i].Attributes = (short)((byte)color | ((byte)color << 4));
                }
            }
        }
Example #2
0
 public void DrawSprite(ConsoleSprite sprite, int x, int y, bool flipHorizontal = false)
 {
     graphics.DrawSprite(sprite, xOffset + x, yOffset + y, flipHorizontal);
 }