Skip to content

Commit

Permalink
Get tiled backgrounds working
Browse files Browse the repository at this point in the history
  • Loading branch information
jonko0493 committed Jan 31, 2023
1 parent cb8c0cc commit 0928620
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/SerialLoops.Lib/Items/BackgroundItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,33 @@ public SKBitmap GetBackground()
{
return Graphic1.GetImage();
}
else if (BackgroundType == BgType.TEX_BOTTOM_TILE_TOP)
{
SKBitmap bitmap = new(Graphic1.Width, Graphic1.Height + Graphic2.Height);
SKCanvas canvas = new(bitmap);

SKBitmap tileBitmap = new(Graphic2.Width, Graphic2.Height);
SKBitmap tiles = Graphic2.GetImage(width: 64);
SKCanvas tileCanvas = new(tileBitmap);
int currentTile = 0;
for (int y = 0; y < tileBitmap.Height; y += 64)
{
for (int x = 0; x < tileBitmap.Width; x += 64)
{
SKRect crop = new(0, currentTile * 64, 64, (currentTile + 1) * 64);
SKRect dest = new(x, y, x + 64, y + 64);
tileCanvas.DrawBitmap(tiles, crop, dest);
currentTile++;
}
}
tileCanvas.Flush();

canvas.DrawBitmap(tileBitmap, new SKPoint(0, 0));
canvas.DrawBitmap(Graphic1.GetImage(), new SKPoint(0, Graphic2.Height));
canvas.Flush();

return bitmap;
}
else if (BackgroundType == BgType.KINETIC_VECTOR)
{
return Graphic2.GetScreenImage(Graphic1);
Expand Down

0 comments on commit 0928620

Please sign in to comment.