position is now center, socket improvements
This commit is contained in:
parent
40eba7a7c7
commit
d4d0abd013
18 changed files with 134 additions and 106 deletions
|
@ -1,16 +0,0 @@
|
|||
using DisplayCommands;
|
||||
using TanksServer.GameLogic;
|
||||
|
||||
namespace TanksServer.Graphics;
|
||||
|
||||
internal sealed class BulletDrawer(BulletManager bullets) : IDrawStep
|
||||
{
|
||||
public void Draw(PixelGrid buffer)
|
||||
{
|
||||
foreach (var bullet in bullets.GetAll())
|
||||
{
|
||||
var pos = bullet.Position.ToPixelPosition();
|
||||
buffer[pos.X, pos.Y] = true;
|
||||
}
|
||||
}
|
||||
}
|
13
TanksServer/Graphics/DrawBulletsStep.cs
Normal file
13
TanksServer/Graphics/DrawBulletsStep.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
using DisplayCommands;
|
||||
using TanksServer.GameLogic;
|
||||
|
||||
namespace TanksServer.Graphics;
|
||||
|
||||
internal sealed class DrawBulletsStep(BulletManager bullets) : IDrawStep
|
||||
{
|
||||
public void Draw(PixelGrid buffer)
|
||||
{
|
||||
foreach (var position in bullets.GetAll().Select(b => b.Position.ToPixelPosition()))
|
||||
buffer[position.X, position.Y] = true;
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ using TanksServer.GameLogic;
|
|||
|
||||
namespace TanksServer.Graphics;
|
||||
|
||||
internal sealed class MapDrawer(MapService map) : IDrawStep
|
||||
internal sealed class DrawMapStep(MapService map) : IDrawStep
|
||||
{
|
||||
public void Draw(PixelGrid buffer)
|
||||
{
|
||||
|
@ -22,4 +22,4 @@ internal sealed class MapDrawer(MapService map) : IDrawStep
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,13 +5,13 @@ using TanksServer.GameLogic;
|
|||
|
||||
namespace TanksServer.Graphics;
|
||||
|
||||
internal sealed class TankDrawer : IDrawStep
|
||||
internal sealed class DrawTanksStep : IDrawStep
|
||||
{
|
||||
private readonly TankManager _tanks;
|
||||
private readonly bool[] _tankSprite;
|
||||
private readonly int _tankSpriteWidth;
|
||||
|
||||
public TankDrawer(TankManager tanks)
|
||||
public DrawTanksStep(TankManager tanks)
|
||||
{
|
||||
_tanks = tanks;
|
||||
|
||||
|
@ -22,9 +22,7 @@ internal sealed class TankDrawer : IDrawStep
|
|||
var i = 0;
|
||||
for (var y = 0; y < tankImage.Height; y++)
|
||||
for (var x = 0; x < tankImage.Width; x++, i++)
|
||||
{
|
||||
_tankSprite[i] = tankImage[x, y] == whitePixel;
|
||||
}
|
||||
|
||||
_tankSpriteWidth = tankImage.Width;
|
||||
}
|
||||
|
@ -33,7 +31,7 @@ internal sealed class TankDrawer : IDrawStep
|
|||
{
|
||||
foreach (var tank in _tanks)
|
||||
{
|
||||
var tankPosition = tank.Position.ToPixelPosition();
|
||||
var tankPosition = tank.Bounds.TopLeft;
|
||||
var orientation = (int)Math.Round(tank.Rotation * 16d) % 16;
|
||||
|
||||
for (byte dy = 0; dy < MapService.TileSize; dy++)
|
||||
|
@ -56,4 +54,4 @@ internal sealed class TankDrawer : IDrawStep
|
|||
|
||||
return _tankSprite[index];
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,8 +3,9 @@ using TanksServer.GameLogic;
|
|||
|
||||
namespace TanksServer.Graphics;
|
||||
|
||||
internal sealed class DrawStateToFrame(
|
||||
IEnumerable<IDrawStep> drawSteps, LastFinishedFrameProvider lastFrameProvider
|
||||
internal sealed class GeneratePixelsTickStep(
|
||||
IEnumerable<IDrawStep> drawSteps,
|
||||
LastFinishedFrameProvider lastFrameProvider
|
||||
) : ITickStep
|
||||
{
|
||||
private readonly List<IDrawStep> _drawSteps = drawSteps.ToList();
|
Loading…
Add table
Add a link
Reference in a new issue