load maps from png files
This commit is contained in:
parent
51334af8c3
commit
6bed7d918f
1 changed files with 85 additions and 60 deletions
|
|
@ -63,14 +63,16 @@ internal sealed class MoveTanks(
|
|||
|
||||
private bool HitsWall(FloatPosition newPosition)
|
||||
{
|
||||
var (topLeft, bottomRight) = Tank.GetBoundsForCenter(newPosition);
|
||||
TilePosition[] positions =
|
||||
[
|
||||
topLeft.ToTilePosition(),
|
||||
new PixelPosition(bottomRight.X, topLeft.Y).ToTilePosition(),
|
||||
new PixelPosition(topLeft.X, bottomRight.Y).ToTilePosition(),
|
||||
bottomRight.ToTilePosition()
|
||||
];
|
||||
return positions.Any(map.IsCurrentlyWall);
|
||||
var (topLeft, _) = Tank.GetBoundsForCenter(newPosition);
|
||||
|
||||
for (short y = 0; y < MapService.TileSize; y++)
|
||||
for (short x = 0; x < MapService.TileSize; x++)
|
||||
{
|
||||
var pixelToCheck = topLeft.GetPixelRelative(x, y);
|
||||
if (map.Current.IsCurrentlyWall(pixelToCheck))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue