add endpoint for requesting map data

This commit is contained in:
Vinzenz Schroeter 2024-05-05 13:51:28 +02:00
parent 079b096c16
commit 5f5e9fb716
8 changed files with 97 additions and 32 deletions

View file

@ -1,18 +1,32 @@
using DisplayCommands;
using TanksServer.GameLogic;
namespace TanksServer.Graphics;
internal sealed class DrawMapStep(MapService map) : IDrawStep
{
public void Draw(GamePixelGrid pixels)
public void Draw(GamePixelGrid pixels) => Draw(pixels, map.Current);
private static void Draw(GamePixelGrid pixels, Map map)
{
for (ushort y = 0; y < MapService.PixelsPerColumn; y++)
for (ushort x = 0; x < MapService.PixelsPerRow; x++)
{
if (!map.Current.IsWall(x, y))
if (!map.IsWall(x, y))
continue;
pixels[x, y].EntityType = GamePixelEntityType.Wall;
}
}
public static void Draw(PixelGrid pixels, Map map)
{
for (ushort y = 0; y < MapService.PixelsPerColumn; y++)
for (ushort x = 0; x < MapService.PixelsPerRow; x++)
{
if (!map.IsWall(x, y))
continue;
pixels[x, y] = true;
}
}
}