Karamushko M.K lab2_base #4

Closed
maxKarme wants to merge 9 commits from lab2_base into lab1_base
Showing only changes of commit 5fb60274de - Show all commits

View File

@ -32,10 +32,12 @@ namespace AirFighter
private (int mapI, int mapJ) checkBarrier((float Left, float Right, float Top, float Bottom) rect)
{
for (int i = (int)(rect.Top / _size_y); i <= (int)(rect.Bottom / _size_y); ++i)
for (int i = (int)(rect.Top / _size_y); i <= (int)(rect.Bottom / _size_y) && i < _map.GetLength(0); ++i)
{
for (int j = (int)(rect.Left / _size_x); j <= (int)(rect.Right / _size_x); ++j)
for (int j = (int)(rect.Left / _size_x); j <= (int)(rect.Right / _size_x) && j < _map.GetLength(1); ++j)
{
if (j < 0) j = 0;
if (i < 0) i = 0;
if (_map[i, j] == _barrier) return (i, j);
}
}
@ -56,6 +58,8 @@ namespace AirFighter
if (direction == Direction.Up) position.Top -= _drawningObject.Step;
if (direction == Direction.Down) position.Top += _drawningObject.Step;
position.Right = position.Left + drawningWidth;
position.Bottom = position.Top + drawningHeight;