bullets collide with walls
This commit is contained in:
parent
b10ccf2da8
commit
898a9cedc1
6 changed files with 50 additions and 28 deletions
|
@ -8,6 +8,6 @@ internal sealed class BulletDrawer(BulletManager bullets): IDrawStep
|
|||
public void Draw(DisplayPixelBuffer buffer)
|
||||
{
|
||||
foreach (var bullet in bullets.GetAll())
|
||||
buffer.Pixels[bullet.Position.ToPixelPosition().GetPixelIndex()] = true;
|
||||
buffer.Pixels[bullet.Position.ToPixelPosition().ToPixelIndex()] = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
using System.Diagnostics;
|
||||
using TanksServer.Models;
|
||||
using TanksServer.Services;
|
||||
|
||||
namespace TanksServer.DrawSteps;
|
||||
|
||||
internal static class DrawHelpers
|
||||
{
|
||||
public static int GetPixelIndex(this PixelPosition position)
|
||||
{
|
||||
return position.Y * MapService.PixelsPerRow + position.X;
|
||||
}
|
||||
|
||||
public static PixelPosition GetPixel(this TilePosition position, byte subX, byte subY)
|
||||
{
|
||||
Debug.Assert(subX < 8);
|
||||
Debug.Assert(subY < 8);
|
||||
return new PixelPosition(
|
||||
X: position.X * MapService.TileSize + subX,
|
||||
Y: position.Y * MapService.TileSize + subY
|
||||
);
|
||||
}
|
||||
}
|
|
@ -18,7 +18,7 @@ internal sealed class MapDrawer(MapService map) : IDrawStep
|
|||
for (byte pixelInTileY = 0; pixelInTileY < MapService.TileSize; pixelInTileY++)
|
||||
for (byte pixelInTileX = 0; pixelInTileX < MapService.TileSize; pixelInTileX++)
|
||||
{
|
||||
var index = tile.GetPixel(pixelInTileX, pixelInTileY).GetPixelIndex();
|
||||
var index = tile.GetPixelRelative(pixelInTileX, pixelInTileY).ToPixelIndex();
|
||||
buffer.Pixels[index] = pixelInTileX % 2 == pixelInTileY % 2;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue