From 230889580525de5bab8029e8e677c28e27ff3e05 Mon Sep 17 00:00:00 2001 From: Katerina881 Date: Thu, 6 Oct 2022 12:29:35 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=B0=D1=80=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirplaneWithRadar/AirplaneWithRadar/SkyMap.cs | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) 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++; + } } } }