Пример #1
0
        public static void WriteChar(ref uint x, uint y, char c, Color col, int alpha = -1)
        {
            int index;
            int cy, cx;

            var unknown = !chars.Contains(c) && !wideChars.Contains(c);
            var wide    = wideChars.Contains(c);

            if (wide)
            {
                index = Array.IndexOf(wideChars, c);
                cx    = index % CHARSACROSS;
                cy    = WIDELINE;
            }
            else
            {
                index = Array.IndexOf(chars, c);
                cx    = index % CHARSACROSS;
                cy    = index / CHARSACROSS;
            }

            var w = wide ? 6 : 4;

            if (cx < 0)
            {
                unknown = true;
            }

            if (c != ' ')
            {
                for (var fx = 0; fx < w; fx++)
                {
                    for (var fy = 0; fy < 6; fy++)
                    {
                        var color = unknown
                        ? ((fx + fy) % 2 == 0 ? Color.White : Color.Black)
                        : font.GetPixel((uint)(cx * w + fx), (uint)(cy * 6 + fy));

                        if (color.ToArgb() != Color.Black.ToArgb() && y + fy > 0 && IsOnScreen((int)x + fx, (int)y + fy))
                        {
                            //paint pixel if it isn't black

                            if (alpha == -1)
                            {
                                screen.SetPixel((uint)(x + fx), (uint)(y + fy), col);
                            }
                            else
                            {
                                var a = screen.GetPixel((uint)(x + fx), (uint)(y + fy));
                                var b = Color.FromArgb(255, 255, 255);

                                screen.SetPixel((uint)(x + fx), (uint)(y + fy), engine.MixColor(a, b, alpha));
                            }
                        }
                    }
                }
            }

            x += (uint)w;
        }
Пример #2
0
        private static void DrawSky(uint x, uint y)
        {
            var sbx = (uint)(x - _sbAngle * (512 / (Math.PI * 2))) - 128;

            screen.SetPixel(x, y, sb.GetPixel(sbx, y));

            _zBuffer[x, y] = 256;
        }
Пример #3
0
 public static void DrawTexture(texture tex, int sx, int sy, int w, int h)
 {
     for (var x = 0; x < w; x++)
     {
         for (var y = 0; y < h; y++)
         {
             var c = tex.GetPixel((uint)x, (uint)y);
             if (c != renderer.magicpink && IsOnScreen(x + sx, y + sy))
             {
                 screen.SetPixel((uint)(x + sx), (uint)(y + sy), c);
             }
         }
     }
 }