load maps from png files
This commit is contained in:
parent
51334af8c3
commit
6bed7d918f
13 changed files with 86 additions and 61 deletions
|
@ -7,19 +7,13 @@ internal sealed class DrawMapStep(MapService map) : IDrawStep
|
|||
{
|
||||
public void Draw(PixelGrid buffer)
|
||||
{
|
||||
for (ushort tileY = 0; tileY < MapService.TilesPerColumn; tileY++)
|
||||
for (ushort tileX = 0; tileX < MapService.TilesPerRow; tileX++)
|
||||
for (ushort y = 0; y < MapService.PixelsPerColumn; y++)
|
||||
for (ushort x = 0; x < MapService.PixelsPerRow; x++)
|
||||
{
|
||||
var tile = new TilePosition(tileX, tileY);
|
||||
if (!map.IsCurrentlyWall(tile))
|
||||
var pixel = new PixelPosition(x, y);
|
||||
if (!map.Current.IsCurrentlyWall(pixel))
|
||||
continue;
|
||||
|
||||
for (byte pixelInTileY = 0; pixelInTileY < MapService.TileSize; pixelInTileY++)
|
||||
for (byte pixelInTileX = 0; pixelInTileX < MapService.TileSize; pixelInTileX++)
|
||||
{
|
||||
var (x, y) = tile.ToPixelPosition().GetPixelRelative(pixelInTileX, pixelInTileY);
|
||||
buffer[(ushort)x, (ushort)y] = pixelInTileX % 2 == pixelInTileY % 2;
|
||||
}
|
||||
buffer[x, y] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,13 +9,14 @@ internal sealed class GeneratePixelsTickStep(
|
|||
) : ITickStep
|
||||
{
|
||||
private readonly List<IDrawStep> _drawSteps = drawSteps.ToList();
|
||||
private readonly PixelGrid _drawGrid = new(MapService.PixelsPerRow, MapService.PixelsPerColumn);
|
||||
|
||||
public Task TickAsync()
|
||||
{
|
||||
var drawGrid = new PixelGrid(MapService.PixelsPerRow, MapService.PixelsPerColumn);
|
||||
_drawGrid.Clear();
|
||||
foreach (var step in _drawSteps)
|
||||
step.Draw(drawGrid);
|
||||
lastFrameProvider.LastFrame = drawGrid;
|
||||
step.Draw(_drawGrid);
|
||||
lastFrameProvider.LastFrame = _drawGrid;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue