infinite map
This commit is contained in:
parent
7213318838
commit
461a9139c2
1 changed files with 101 additions and 69 deletions
|
|
@ -10,19 +10,25 @@ internal static class PositionHelpers
|
|||
Debug.Assert(subX < 8);
|
||||
Debug.Assert(subY < 8);
|
||||
return new PixelPosition(
|
||||
X: (ushort)(position.X * MapService.TileSize + subX),
|
||||
Y: (ushort)(position.Y * MapService.TileSize + subY)
|
||||
x: (ushort)(position.X * MapService.TileSize + subX),
|
||||
y: (ushort)(position.Y * MapService.TileSize + subY)
|
||||
);
|
||||
}
|
||||
|
||||
public static PixelPosition GetPixelRelative(this PixelPosition position, byte subX, byte subY)
|
||||
{
|
||||
Debug.Assert(subX < 8);
|
||||
Debug.Assert(subY < 8);
|
||||
return new PixelPosition((ushort)(position.X + subX), (ushort)(position.Y + subY));
|
||||
}
|
||||
|
||||
public static PixelPosition ToPixelPosition(this FloatPosition position) => new(
|
||||
X: (ushort)((int)position.X % MapService.PixelsPerRow),
|
||||
Y: (ushort)((int)position.Y % MapService.PixelsPerRow)
|
||||
x: (ushort)((int)position.X % MapService.PixelsPerRow),
|
||||
y: (ushort)((int)position.Y % MapService.PixelsPerRow)
|
||||
);
|
||||
|
||||
public static TilePosition ToTilePosition(this PixelPosition position) => new(
|
||||
X: position.X / MapService.TileSize,
|
||||
Y: position.Y / MapService.TileSize
|
||||
x: (ushort)(position.X / MapService.TileSize),
|
||||
y: (ushort)(position.Y / MapService.TileSize)
|
||||
);
|
||||
}
|
||||
Reference in a new issue