2024-04-12 16:05:24 +02:00
|
|
|
using DisplayCommands;
|
2024-04-10 19:25:45 +02:00
|
|
|
using TanksServer.GameLogic;
|
2024-04-07 19:05:50 +02:00
|
|
|
|
2024-04-10 19:25:45 +02:00
|
|
|
namespace TanksServer.Graphics;
|
2024-04-07 19:05:50 +02:00
|
|
|
|
2024-04-13 14:07:14 +02:00
|
|
|
internal sealed class DrawMapStep(MapService map) : IDrawStep
|
2024-04-07 19:05:50 +02:00
|
|
|
{
|
2024-04-12 16:05:24 +02:00
|
|
|
public void Draw(PixelGrid buffer)
|
2024-04-07 19:05:50 +02:00
|
|
|
{
|
2024-04-12 18:32:10 +02:00
|
|
|
for (ushort tileY = 0; tileY < MapService.TilesPerColumn; tileY++)
|
|
|
|
for (ushort tileX = 0; tileX < MapService.TilesPerRow; tileX++)
|
2024-04-07 19:05:50 +02:00
|
|
|
{
|
|
|
|
var tile = new TilePosition(tileX, tileY);
|
|
|
|
if (!map.IsCurrentlyWall(tile))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (byte pixelInTileY = 0; pixelInTileY < MapService.TileSize; pixelInTileY++)
|
|
|
|
for (byte pixelInTileX = 0; pixelInTileX < MapService.TileSize; pixelInTileX++)
|
|
|
|
{
|
2024-04-13 16:27:45 +02:00
|
|
|
var (x, y) = tile.ToPixelPosition().GetPixelRelative(pixelInTileX, pixelInTileY);
|
|
|
|
buffer[(ushort)x, (ushort)y] = pixelInTileX % 2 == pixelInTileY % 2;
|
2024-04-07 19:05:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-04-13 14:07:14 +02:00
|
|
|
}
|