player can shoot bullet (crashes game when leaving map)
This commit is contained in:
parent
dd6b0fffc1
commit
b10ccf2da8
1 changed files with 230 additions and 98 deletions
23
TanksServer/DrawSteps/DrawHelpers.cs
Normal file
23
TanksServer/DrawSteps/DrawHelpers.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in a new issue