From 6e1a5eb9c4f315bef2c52e61da9028a468212bc5 Mon Sep 17 00:00:00 2001 From: malimova Date: Mon, 2 Oct 2023 20:28:53 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B8,=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=B2=D0=B5=D1=80=D1=88=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B2=D0=BE=D0=B9=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D1=80=D0=BD=D0=BE=D0=B9=20=D1=80=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/DrawningAirBomber.cs | 42 ++++++------------------ AirBomber/AirBomber/EntityAirBomber.cs | 10 ------ AirBomber/AirBomber/FormAirBomber.cs | 18 ++-------- AirBomber/AirBomber/Program.cs | 1 + 4 files changed, 14 insertions(+), 57 deletions(-) diff --git a/AirBomber/AirBomber/DrawningAirBomber.cs b/AirBomber/AirBomber/DrawningAirBomber.cs index 088096c..c448135 100644 --- a/AirBomber/AirBomber/DrawningAirBomber.cs +++ b/AirBomber/AirBomber/DrawningAirBomber.cs @@ -12,26 +12,12 @@ namespace AirBomber public EntityAirBomber? EntityAirBomber { get; private set; } private int _pictureWidth; private int _pictureHeight; - /// - /// Левая координата прорисовки бобмбардировщика - /// private int _startPosX; - /// - /// Верхняя кооридната прорисовки бомбардировщика - /// private int _startPosY; - /// - /// Ширина прорисовки бомбардировщика - /// - private readonly int _bomberWidth = 150; - /// - /// Высота прорисовки бомбардировщика - /// - private readonly int _bomberHeight = 120; - /// true - объект создан, false - проверка не пройдена, нельзя создать объект в этих размерах + private readonly int _bomberWidth = 160; + private readonly int _bomberHeight = 118; public bool Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bombs, Color bombsColor, bool fuelTanks, int width, int height) { - // TODO: Продумать проверки _pictureWidth = width; _pictureHeight = height; if (width < _bomberWidth || height < _bomberHeight) @@ -42,28 +28,20 @@ namespace AirBomber EntityAirBomber.Init(speed, weight, bodyColor, additionalColor, bombs, bombsColor, fuelTanks); return true; } - /// - /// Установка позиции - /// - /// Координата X - /// Координата Y public void SetPosition(int x, int y) { - if (x < 0 || x + _bomberWidth > _pictureWidth) + if (x < 0 || x + _bomberWidth > _pictureWidth) { - x = 15; + x = _pictureWidth - _bomberWidth; } - if (y < 0 || y + _bomberHeight > _pictureHeight) + + if (y < 0 || y + _bomberWidth > _pictureHeight) { - y = 15; + y = _pictureHeight - _bomberHeight; } _startPosX = x; _startPosY = y; } - /// - /// Изменение направления перемещения - /// - /// Направление public void MoveTransport(DirectionType direction) { if (EntityAirBomber == null) @@ -109,16 +87,16 @@ namespace AirBomber Brush bodyColor = new SolidBrush(EntityAirBomber.BodyColor); Brush bombsColor = new SolidBrush(EntityAirBomber.BombsColor); Brush wingsColor = new SolidBrush(Color.DeepPink); - // bombs if (EntityAirBomber.Bombs) { g.FillEllipse(bombsColor, _startPosX + 90, _startPosY + 20, 15, 29); g.DrawEllipse(pen, _startPosX + 90, _startPosY + 20, 15, 29); g.FillEllipse(bombsColor, _startPosX + 90, _startPosY + 70, 15, 29); g.DrawEllipse(pen, _startPosX + 90, _startPosY + 70, 15, 29); - + g.FillEllipse(bombsColor, _startPosX + 140, _startPosY + 50, 15, 15); + g.DrawEllipse(pen, _startPosX + 140, _startPosY + 50, 15, 15); + } - //границы бомбера g.FillPolygon(additionalBrush, new Point[] //nose { new Point(_startPosX + 19, _startPosY + 50), diff --git a/AirBomber/AirBomber/EntityAirBomber.cs b/AirBomber/AirBomber/EntityAirBomber.cs index 133015d..1a7de6d 100644 --- a/AirBomber/AirBomber/EntityAirBomber.cs +++ b/AirBomber/AirBomber/EntityAirBomber.cs @@ -8,7 +8,6 @@ namespace AirBomber { public class EntityAirBomber { - public int Speed { get; private set; } public double Weight { get; private set; } public Color BodyColor { get; private set; } @@ -17,15 +16,6 @@ namespace AirBomber public Color BombsColor { get; private set; } public bool FuelTanks { get; private set; } public double Step => (double)Speed * 100 / Weight; - /// - /// Инициализация полей объекта-класса спортивного автомобиля - /// - /// Скорость - /// Вес бомбардировщика - /// Основной цвет - /// Дополнительный цвет - /// Признак наличия бомб - /// Признак наличия топливных баков public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bombs, Color bombsColor, bool fuelTanks) { diff --git a/AirBomber/AirBomber/FormAirBomber.cs b/AirBomber/AirBomber/FormAirBomber.cs index b2b6357..cf453fb 100644 --- a/AirBomber/AirBomber/FormAirBomber.cs +++ b/AirBomber/AirBomber/FormAirBomber.cs @@ -2,11 +2,7 @@ { public partial class FormAirBomber : Form { - /// - /// Поле-объект для прорисовки объекта - /// private DrawningAirBomber? _drawningAirBomber; - public FormAirBomber() { InitializeComponent(); @@ -22,11 +18,6 @@ _drawningAirBomber.DrawBomber(gr); pictureBoxAirBomber.Image = bmp; } - /// - /// Обработка нажатия кнопки "Создать" - /// - /// - /// private void buttonCreate_Click(object sender, EventArgs e) { Random random = new(); @@ -34,14 +25,11 @@ _drawningAirBomber.Init(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), Convert.ToBoolean(random.Next(0, 2)), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), - Convert.ToBoolean(random.Next(0, 2)), pictureBoxAirBomber.Width, pictureBoxAirBomber.Height); _drawningAirBomber.SetPosition(random.Next(10, 100), random.Next(10, 100)); + Convert.ToBoolean(random.Next(0, 2)), pictureBoxAirBomber.Width, pictureBoxAirBomber.Height); + + _drawningAirBomber.SetPosition(random.Next(10, 100), random.Next(10, 100)); Draw(); } - /// - /// Изменение размеров формы - /// - /// - /// private void buttonMove_Click(object sender, EventArgs e) { if (_drawningAirBomber == null) diff --git a/AirBomber/AirBomber/Program.cs b/AirBomber/AirBomber/Program.cs index 76b85fe..f167f45 100644 --- a/AirBomber/AirBomber/Program.cs +++ b/AirBomber/AirBomber/Program.cs @@ -7,6 +7,7 @@ namespace AirBomber /// [STAThread] static void Main() + { // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration.