separate folders per functionality
This commit is contained in:
parent
7f00160780
commit
0ca6a91a7e
33 changed files with 60 additions and 113 deletions
30
TanksServer/Models/PositionHelpers.cs
Normal file
30
TanksServer/Models/PositionHelpers.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
using System.Diagnostics;
|
||||
using TanksServer.GameLogic;
|
||||
|
||||
namespace TanksServer.Models;
|
||||
|
||||
internal static class PositionHelpers
|
||||
{
|
||||
public static int ToPixelIndex(this PixelPosition position) => position.Y * MapService.PixelsPerRow + position.X;
|
||||
|
||||
public static PixelPosition GetPixelRelative(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
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public static PixelPosition ToPixelPosition(this FloatPosition position) => new(
|
||||
X: (int)position.X % MapService.PixelsPerRow,
|
||||
Y: (int)position.Y % MapService.PixelsPerRow
|
||||
);
|
||||
|
||||
public static TilePosition ToTilePosition(this PixelPosition position) => new(
|
||||
X: position.X / MapService.TileSize,
|
||||
Y: position.Y / MapService.TileSize
|
||||
);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
using TanksServer.Services;
|
||||
using TanksServer.GameLogic;
|
||||
|
||||
namespace TanksServer.Models;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue