servicepoint-tanks/TanksServer/Graphics/MapDrawer.cs

25 lines
874 B
C#
Raw Normal View History

using DisplayCommands;
2024-04-10 19:25:45 +02:00
using TanksServer.GameLogic;
2024-04-10 19:25:45 +02:00
namespace TanksServer.Graphics;
internal sealed class MapDrawer(MapService map) : IDrawStep
{
public void Draw(PixelGrid buffer)
{
2024-04-12 18:32:10 +02:00
for (ushort tileY = 0; tileY < MapService.TilesPerColumn; tileY++)
for (ushort tileX = 0; tileX < MapService.TilesPerRow; tileX++)
{
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-10 22:39:33 +02:00
var position = tile.GetPixelRelative(pixelInTileX, pixelInTileY);
buffer[position.X, position.Y] = pixelInTileX % 2 == pixelInTileY % 2;
}
}
}
}