Example #1
0
        public void Draw(int frame, int x, int y, BitsyGame.Color c, IRenderSurface context, int pixelScale = 1)
        {
            if (context == null)
            {
                return;
            }
            if (frame < 0 || frame >= frameCount)
            {
                return;
            }

            int offset = frame * width * height;

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    if (_pixels[offset + j * width + i])
                    {
                        int px = x + i * pixelScale;
                        int py = y + j * pixelScale;
                        if (pixelScale == 1)
                        {
                            context.SetPixel(c, px, py);
                        }
                        else
                        {
                            for (int sx = 0; sx < pixelScale; sx++)
                            {
                                for (int sy = 0; sy < pixelScale; sy++)
                                {
                                    context.SetPixel(c, px + sx, py + sy);
                                }
                            }
                        }
                    }
                }
            }
        }
Example #2
0
 public static void FillArea(this IRenderSurface surface, BitsyGame.Color c, int x, int y, int width, int height)
 {
     if (surface == null)
     {
         return;
     }
     for (int i = 0; i < width; i++)
     {
         for (int j = 0; j < height; j++)
         {
             surface.SetPixel(c, x + i, y + j);
         }
     }
 }
Example #3
0
        public void FillTile(BitsyGame.Color color, int x, int y, IRenderSurface context)
        {
            if (context == null)
            {
                return;
            }

            for (int i = 0; i < BitsyGame.TILESIZE * BitsyGame.PIXEL_SCALE; i++)
            {
                for (int j = 0; j < BitsyGame.TILESIZE * BitsyGame.PIXEL_SCALE; j++)
                {
                    context.SetPixel(color, x + i, y + j);
                }
            }
        }
Example #4
0
        public static void SetPixels(this IRenderSurface surface, BitsyGame.Color[] pixels, int x, int y, int width, int height)
        {
            int dim = width * height;

            if (dim > pixels.Length)
            {
                throw new System.ArgumentException("pixels array is wrong size");
            }

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    int k = j * width + i;
                    surface.SetPixel(pixels[k], x + i, y + j);
                }
            }
        }