diff --git a/AirplaneWithRadar/AirplaneWithRadar/SkyMap.cs b/AirplaneWithRadar/AirplaneWithRadar/SkyMap.cs index b09abf6..da33fdc 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/SkyMap.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/SkyMap.cs @@ -22,7 +22,7 @@ namespace AirplaneWithRadar protected override void DrawBarrierPart(Graphics g, int i, int j) { - g.FillEllipse(barrierColor, i * (_size_x - 1), j * (_size_y - 1), 40, 24); + g.FillRectangle(barrierColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1)); } protected override void DrawRoadPart(Graphics g, int i, int j) { @@ -41,14 +41,31 @@ namespace AirplaneWithRadar _map[i, j] = _freeRoad; } } - while (counter < 15) + while (counter < 10) { int x = _random.Next(0, 100); int y = _random.Next(0, 100); - if (_map[x, y] == _freeRoad) + if (x - 2 >=0 && y + 4 < 100 && x + 2 < 100) { - _map[x, y] = _barrier; - counter++; + if (_map[x, y] == _freeRoad && _map[x + 1, y + 1] == _freeRoad && _map[x - 1, y + 1] == _freeRoad && _map[x, y + 2] == _freeRoad && _map[x, y + 1] == _freeRoad + && _map[x + 2, y + 2] == _freeRoad && _map[x - 2, y + 2] == _freeRoad && _map[x + 1, y + 3] == _freeRoad && _map[x - 1, y + 3] == _freeRoad + && _map[x, y + 3] == _freeRoad && _map[x, y + 4] == _freeRoad && _map[x + 1, y + 2] == _freeRoad && _map[x - 1, y + 2] == _freeRoad) + { + _map[x, y] = _barrier; + _map[x + 1, y + 1] = _barrier; + _map[x - 1, y + 1] = _barrier; + _map[x + 2, y + 2] = _barrier; + _map[x - 2, y + 2] = _barrier; + _map[x, y + 2] = _barrier; + _map[x, y + 1] = _barrier; + _map[x + 1, y + 3] = _barrier; + _map[x - 1, y + 3] = _barrier; + _map[x, y + 3] = _barrier; + _map[x, y + 4] = _barrier; + _map[x + 1, y + 2] = _barrier; + _map[x - 1, y + 2] = _barrier; + counter++; + } } } }