From cf72203a1cd14858357d23583d98dd4e21a9a4b9 Mon Sep 17 00:00:00 2001 From: malimova Date: Mon, 18 Sep 2023 11:53:40 +0400 Subject: [PATCH 1/6] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=B0-=D1=81=D1=83?= =?UTF-8?q?=D1=89=D0=BD=D0=BE=D1=81=D1=82=D0=B8=20=D0=BE=D0=B1=D1=8A=D0=B5?= =?UTF-8?q?=D0=BA=D1=82=D0=B0=20"=D0=91=D0=BE=D0=BC=D0=B1=D0=B0=D1=80?= =?UTF-8?q?=D0=B4=D0=B8=D1=80=D0=BE=D0=B2=D1=89=D0=B8=D0=BA"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/EntityAirBomber.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 AirBomber/AirBomber/EntityAirBomber.cs diff --git a/AirBomber/AirBomber/EntityAirBomber.cs b/AirBomber/AirBomber/EntityAirBomber.cs new file mode 100644 index 0000000..d1af57d --- /dev/null +++ b/AirBomber/AirBomber/EntityAirBomber.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AirBomber +{ + internal class EntityAirBomber + { + } +} -- 2.25.1 From 6e1fa7e9ec9a6fd4d5116f7a061b3e29afb0b243 Mon Sep 17 00:00:00 2001 From: malimova Date: Sat, 30 Sep 2023 20:28:12 +0400 Subject: [PATCH 2/6] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=B0=20Direction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/Direction.cs | 12 +++++++++++ AirBomber/AirBomber/EntityAirBomber.cs | 30 +++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 AirBomber/AirBomber/Direction.cs diff --git a/AirBomber/AirBomber/Direction.cs b/AirBomber/AirBomber/Direction.cs new file mode 100644 index 0000000..eb271bc --- /dev/null +++ b/AirBomber/AirBomber/Direction.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AirBomber +{ + internal class Direction + { + } +} diff --git a/AirBomber/AirBomber/EntityAirBomber.cs b/AirBomber/AirBomber/EntityAirBomber.cs index d1af57d..fa37724 100644 --- a/AirBomber/AirBomber/EntityAirBomber.cs +++ b/AirBomber/AirBomber/EntityAirBomber.cs @@ -6,7 +6,35 @@ using System.Threading.Tasks; namespace AirBomber { - internal class EntityAirBomber + public class EntityAirBomber { + + public int Speed { get; private set; } + public double Weight { get; private set; } + public Color BodyColor { get; private set; } + public Color AdditionalColor { get; private set; } + public bool Bombs { 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, bool fueltanks) + { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + AdditionalColor = additionalColor; + Bombs = bombs; + FuelTanks = fueltanks; + } + } } -- 2.25.1 From ff4b2f7e71c793379381a7b6b5451110705f16db Mon Sep 17 00:00:00 2001 From: malimova Date: Sun, 1 Oct 2023 14:43:56 +0400 Subject: [PATCH 3/6] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=B0=20Drawning,=20?= =?UTF-8?q?=D1=80=D0=B0=D0=B7=D0=BC=D0=B5=D1=89=D0=B5=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D1=8D=D0=BB=D0=B5=D0=BC=D0=B5=D0=BD=D1=82=D0=BE=D0=B2=20=D0=BD?= =?UTF-8?q?=D0=B0=20=D1=84=D0=BE=D1=80=D0=BC=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/AirBomber.csproj | 15 ++ AirBomber/AirBomber/Direction.cs | 6 +- AirBomber/AirBomber/DrawningAirBomber.cs | 211 ++++++++++++++++++ AirBomber/AirBomber/EntityAirBomber.cs | 6 +- AirBomber/AirBomber/Form1.Designer.cs | 39 ---- AirBomber/AirBomber/FormAirBomber.Designer.cs | 115 ++++++++++ .../AirBomber/{Form1.cs => FormAirBomber.cs} | 4 +- AirBomber/AirBomber/FormAirBomber.resx | 60 +++++ AirBomber/AirBomber/Program.cs | 2 +- .../Properties/Resources.Designer.cs | 103 +++++++++ .../{Form1.resx => Properties/Resources.resx} | 13 ++ AirBomber/AirBomber/Resources/arrowDown.png | Bin 0 -> 1831 bytes AirBomber/AirBomber/Resources/arrowLeft.png | Bin 0 -> 1920 bytes AirBomber/AirBomber/Resources/arrowRight.png | Bin 0 -> 1920 bytes AirBomber/AirBomber/Resources/arrowUp.png | Bin 0 -> 2681 bytes 15 files changed, 528 insertions(+), 46 deletions(-) create mode 100644 AirBomber/AirBomber/DrawningAirBomber.cs delete mode 100644 AirBomber/AirBomber/Form1.Designer.cs create mode 100644 AirBomber/AirBomber/FormAirBomber.Designer.cs rename AirBomber/AirBomber/{Form1.cs => FormAirBomber.cs} (53%) create mode 100644 AirBomber/AirBomber/FormAirBomber.resx create mode 100644 AirBomber/AirBomber/Properties/Resources.Designer.cs rename AirBomber/AirBomber/{Form1.resx => Properties/Resources.resx} (83%) create mode 100644 AirBomber/AirBomber/Resources/arrowDown.png create mode 100644 AirBomber/AirBomber/Resources/arrowLeft.png create mode 100644 AirBomber/AirBomber/Resources/arrowRight.png create mode 100644 AirBomber/AirBomber/Resources/arrowUp.png diff --git a/AirBomber/AirBomber/AirBomber.csproj b/AirBomber/AirBomber/AirBomber.csproj index b57c89e..13ee123 100644 --- a/AirBomber/AirBomber/AirBomber.csproj +++ b/AirBomber/AirBomber/AirBomber.csproj @@ -8,4 +8,19 @@ enable + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/AirBomber/AirBomber/Direction.cs b/AirBomber/AirBomber/Direction.cs index eb271bc..3615f98 100644 --- a/AirBomber/AirBomber/Direction.cs +++ b/AirBomber/AirBomber/Direction.cs @@ -6,7 +6,11 @@ using System.Threading.Tasks; namespace AirBomber { - internal class Direction + public enum DirectionType { + Up = 1, + Down = 2, + Left = 3, + Right = 4 } } diff --git a/AirBomber/AirBomber/DrawningAirBomber.cs b/AirBomber/AirBomber/DrawningAirBomber.cs new file mode 100644 index 0000000..69c74da --- /dev/null +++ b/AirBomber/AirBomber/DrawningAirBomber.cs @@ -0,0 +1,211 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AirBomber +{ + public class DrawningAirBomber + { + public EntityAirBomber? EntityAirBomber { get; private set; } + private int _pictureWidth; + private int _pictureHeight; + /// + /// Левая координата прорисовки бобмбардировщика + /// + private int _startPosX; + /// + /// Верхняя кооридната прорисовки бомбардировщика + /// + private int _startPosY; + /// + /// Ширина прорисовки бомбардировщика + /// + private readonly int _bomberWidth = 110; + /// + /// Высота прорисовки бомбардировщика + /// + private readonly int _bomberHeight = 60; + /// + /// Инициализация свойств + /// + /// Скорость + /// Вес + /// Цвет кузова + /// Дополнительный цвет + /// Признак наличия бомб + /// Признак наличия топливных баков + /// Ширина картинки + /// Высота картинки + /// true - объект создан, false - проверка не пройдена, нельзя создать объект в этих размерах + public bool Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bombs, bool fuelTanks, int width, int height) + { + // TODO: Продумать проверки + _pictureWidth = width; + _pictureHeight = height; + EntityAirBomber = new EntityAirBomber(); + EntityAirBomber.Init(speed, weight, bodyColor, additionalColor, bombs, fuelTanks); + return true; + } + /// + /// Установка позиции + /// + /// Координата X + /// Координата Y + public void SetPosition(int x, int y) + { + // TODO: Изменение x, y + _startPosX = x; + _startPosY = y; + } + /// + /// Изменение направления перемещения + /// + /// Направление + public void MoveTransport(DirectionType direction) + { + if (EntityAirBomber == null) + { + return; + } + switch (direction) + { + //влево + case DirectionType.Left: + if (_startPosX - EntityAirBomber.Step > 0) + { + _startPosX -= (int)EntityAirBomber.Step; + } + break; + //вверх + case DirectionType.Up: + if (_startPosY - EntityAirBomber.Step > 0) + { + _startPosY -= (int)EntityAirBomber.Step; + } + break; + // вправо + case DirectionType.Right: + // TODO: Продумать логику + break; + //вниз + case DirectionType.Down: + // TODO: Продумать логику + break; + } + } + /// + /// Прорисовка объекта + /// + /// + public void DrawTransport(Graphics g) + { + if (EntityAirBomber == null) + { + return; + } + Pen pen = new(Color.Black); + Brush additionalBrush = new + SolidBrush(EntityAirBomber.AdditionalColor); + // обвесы + if (EntityAirBomber.Bombs) + { + g.DrawEllipse(pen, _startPosX + 90, _startPosY, 20, 20); + g.DrawEllipse(pen, _startPosX + 90, _startPosY + 40, 20, + 20); + g.DrawRectangle(pen, _startPosX + 90, _startPosY + 10, + 20, 40); + g.DrawRectangle(pen, _startPosX + 90, _startPosY, 15, + 15); + g.DrawRectangle(pen, _startPosX + 90, _startPosY + 45, + 15, 15); + g.FillEllipse(additionalBrush, _startPosX + 90, + _startPosY, 20, 20); + g.FillEllipse(additionalBrush, _startPosX + 90, + _startPosY + 40, 20, 20); + g.FillRectangle(additionalBrush, _startPosX + 90, + _startPosY + 10, 20, 40); + g.FillRectangle(additionalBrush, _startPosX + 90, _startPosY + 1, 15, 15); + g.FillRectangle(additionalBrush, _startPosX + 90, + _startPosY + 45, 15, 15); + g.DrawEllipse(pen, _startPosX, _startPosY, 20, 20); + g.DrawEllipse(pen, _startPosX, _startPosY + 40, 20, 20); + g.DrawRectangle(pen, _startPosX, _startPosY + 10, 20, + 40); + g.DrawRectangle(pen, _startPosX + 5, _startPosY, 14, + 15); + g.DrawRectangle(pen, _startPosX + 5, _startPosY + 45, + 14, 15); + g.FillEllipse(additionalBrush, _startPosX, _startPosY, + 20, 20); + g.FillEllipse(additionalBrush, _startPosX, _startPosY + + 40, 20, 20); + g.FillRectangle(additionalBrush, _startPosX + 1, + _startPosY + 10, 25, 40); + g.FillRectangle(additionalBrush, _startPosX + 5, + _startPosY + 1, 15, 15); + g.FillRectangle(additionalBrush, _startPosX + 5, + _startPosY + 45, 15, 15); + g.DrawRectangle(pen, _startPosX + 35, _startPosY, 39, + 15); + g.DrawRectangle(pen, _startPosX + 35, _startPosY + 45, + 39, 15); + g.FillRectangle(additionalBrush, _startPosX + 35, + _startPosY + 1, 40, 15); + g.FillRectangle(additionalBrush, _startPosX + 35, + _startPosY + 45, 40, 15); + } + //границы автомобиля + g.DrawEllipse(pen, _startPosX + 10, _startPosY + 5, 20, 20); + g.DrawEllipse(pen, _startPosX + 10, _startPosY + 35, 20, 20); + g.DrawEllipse(pen, _startPosX + 80, _startPosY + 5, 20, 20); + g.DrawEllipse(pen, _startPosX + 80, _startPosY + 35, 20, 20); + g.DrawRectangle(pen, _startPosX + 9, _startPosY + 15, 10, 30); + g.DrawRectangle(pen, _startPosX + 90, _startPosY + 15, 10, + 30); + g.DrawRectangle(pen, _startPosX + 20, _startPosY + 4, 70, 52); + //задние фары + Brush brRed = new SolidBrush(Color.Red); + g.FillEllipse(brRed, _startPosX + 10, _startPosY + 5, 20, 20); + g.FillEllipse(brRed, _startPosX + 10, _startPosY + 35, 20, + 20); + //передние фары + Brush brYellow = new SolidBrush(Color.Yellow); + g.FillEllipse(brYellow, _startPosX + 80, _startPosY + 5, 20, + 20); + g.FillEllipse(brYellow, _startPosX + 80, _startPosY + 35, 20, + 20); + //кузов + Brush br = new SolidBrush(EntityAirBomber.BodyColor); + g.FillRectangle(br, _startPosX + 10, _startPosY + 15, 10, 30); + g.FillRectangle(br, _startPosX + 90, _startPosY + 15, 10, 30); + g.FillRectangle(br, _startPosX + 20, _startPosY + 5, 70, 50); + //стекла + Brush brBlue = new SolidBrush(Color.LightBlue); + g.FillRectangle(brBlue, _startPosX + 70, _startPosY + 10, 5, + 40); + g.FillRectangle(brBlue, _startPosX + 30, _startPosY + 10, 5, + 40); + g.FillRectangle(brBlue, _startPosX + 35, _startPosY + 8, 35, + 2); + g.FillRectangle(brBlue, _startPosX + 35, _startPosY + 51, 35, + 2); + //выделяем рамкой крышу + g.DrawRectangle(pen, _startPosX + 35, _startPosY + 10, 35, + 40); + g.DrawRectangle(pen, _startPosX + 75, _startPosY + 15, 25, + 30); + g.DrawRectangle(pen, _startPosX + 10, _startPosY + 15, 15, + 30); + // крыло + if (EntityAirBomber.FuelTanks) + { + g.FillRectangle(additionalBrush, _startPosX, _startPosY + + 5, 10, 50); + g.DrawRectangle(pen, _startPosX, _startPosY + 5, 10, + 50); + } + } + } +} diff --git a/AirBomber/AirBomber/EntityAirBomber.cs b/AirBomber/AirBomber/EntityAirBomber.cs index fa37724..a4907a1 100644 --- a/AirBomber/AirBomber/EntityAirBomber.cs +++ b/AirBomber/AirBomber/EntityAirBomber.cs @@ -24,16 +24,16 @@ namespace AirBomber /// Основной цвет /// Дополнительный цвет /// Признак наличия бомб - /// Признак наличия топливных баков + /// Признак наличия топливных баков public void Init(int speed, double weight, Color bodyColor, Color - additionalColor, bool bombs, bool fueltanks) + additionalColor, bool bombs, bool fuelTanks) { Speed = speed; Weight = weight; BodyColor = bodyColor; AdditionalColor = additionalColor; Bombs = bombs; - FuelTanks = fueltanks; + FuelTanks = fuelTanks; } } diff --git a/AirBomber/AirBomber/Form1.Designer.cs b/AirBomber/AirBomber/Form1.Designer.cs deleted file mode 100644 index 185eea6..0000000 --- a/AirBomber/AirBomber/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace AirBomber -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; - } - - #endregion - } -} \ No newline at end of file diff --git a/AirBomber/AirBomber/FormAirBomber.Designer.cs b/AirBomber/AirBomber/FormAirBomber.Designer.cs new file mode 100644 index 0000000..6ad235b --- /dev/null +++ b/AirBomber/AirBomber/FormAirBomber.Designer.cs @@ -0,0 +1,115 @@ +namespace AirBomber +{ + partial class FormAirBomber + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + buttonCreate = new Button(); + buttonDown = new Button(); + buttonLeft = new Button(); + buttonRight = new Button(); + buttonUp = new Button(); + SuspendLayout(); + // + // buttonCreate + // + buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonCreate.Location = new Point(29, 479); + buttonCreate.Name = "buttonCreate"; + buttonCreate.Size = new Size(148, 34); + buttonCreate.TabIndex = 0; + buttonCreate.Text = "Создать"; + buttonCreate.UseVisualStyleBackColor = true; + // + // buttonDown + // + buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonDown.BackgroundImage = Properties.Resources.arrowDown; + buttonDown.BackgroundImageLayout = ImageLayout.Zoom; + buttonDown.Location = new Point(842, 483); + buttonDown.Name = "buttonDown"; + buttonDown.Size = new Size(30, 30); + buttonDown.TabIndex = 1; + buttonDown.UseVisualStyleBackColor = true; + // + // buttonLeft + // + buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonLeft.BackgroundImage = Properties.Resources.arrowLeft; + buttonLeft.BackgroundImageLayout = ImageLayout.Zoom; + buttonLeft.Location = new Point(806, 483); + buttonLeft.Name = "buttonLeft"; + buttonLeft.Size = new Size(30, 30); + buttonLeft.TabIndex = 2; + buttonLeft.UseVisualStyleBackColor = true; + // + // buttonRight + // + buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonRight.BackgroundImage = Properties.Resources.arrowRight; + buttonRight.BackgroundImageLayout = ImageLayout.Zoom; + buttonRight.Location = new Point(878, 483); + buttonRight.Name = "buttonRight"; + buttonRight.Size = new Size(30, 30); + buttonRight.TabIndex = 3; + buttonRight.UseVisualStyleBackColor = true; + // + // buttonUp + // + buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonUp.BackgroundImage = Properties.Resources.arrowUp; + buttonUp.BackgroundImageLayout = ImageLayout.Zoom; + buttonUp.Location = new Point(842, 447); + buttonUp.Name = "buttonUp"; + buttonUp.Size = new Size(30, 30); + buttonUp.TabIndex = 4; + buttonUp.UseVisualStyleBackColor = true; + // + // FormAirBomber + // + AutoScaleDimensions = new SizeF(10F, 25F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(986, 540); + Controls.Add(buttonUp); + Controls.Add(buttonRight); + Controls.Add(buttonLeft); + Controls.Add(buttonDown); + Controls.Add(buttonCreate); + Name = "FormAirBomber"; + Text = "Form1"; + ResumeLayout(false); + } + + #endregion + + private Button buttonCreate; + private Button buttonDown; + private Button buttonLeft; + private Button buttonRight; + private Button buttonUp; + } +} \ No newline at end of file diff --git a/AirBomber/AirBomber/Form1.cs b/AirBomber/AirBomber/FormAirBomber.cs similarity index 53% rename from AirBomber/AirBomber/Form1.cs rename to AirBomber/AirBomber/FormAirBomber.cs index 0ca8021..e998b26 100644 --- a/AirBomber/AirBomber/Form1.cs +++ b/AirBomber/AirBomber/FormAirBomber.cs @@ -1,8 +1,8 @@ namespace AirBomber { - public partial class Form1 : Form + public partial class FormAirBomber : Form { - public Form1() + public FormAirBomber() { InitializeComponent(); } diff --git a/AirBomber/AirBomber/FormAirBomber.resx b/AirBomber/AirBomber/FormAirBomber.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/AirBomber/AirBomber/FormAirBomber.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/AirBomber/AirBomber/Program.cs b/AirBomber/AirBomber/Program.cs index 34d9512..76b85fe 100644 --- a/AirBomber/AirBomber/Program.cs +++ b/AirBomber/AirBomber/Program.cs @@ -11,7 +11,7 @@ namespace AirBomber // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + Application.Run(new FormAirBomber()); } } } \ No newline at end of file diff --git a/AirBomber/AirBomber/Properties/Resources.Designer.cs b/AirBomber/AirBomber/Properties/Resources.Designer.cs new file mode 100644 index 0000000..c458e7e --- /dev/null +++ b/AirBomber/AirBomber/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace AirBomber.Properties { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом StronglyTypedResourceBuilder + // с помощью такого средства, как ResGen или Visual Studio. + // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen + // с параметром /str или перестройте свой проект VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AirBomber.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arrowDown { + get { + object obj = ResourceManager.GetObject("arrowDown", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arrowLeft { + get { + object obj = ResourceManager.GetObject("arrowLeft", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arrowRight { + get { + object obj = ResourceManager.GetObject("arrowRight", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arrowUp { + get { + object obj = ResourceManager.GetObject("arrowUp", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/AirBomber/AirBomber/Form1.resx b/AirBomber/AirBomber/Properties/Resources.resx similarity index 83% rename from AirBomber/AirBomber/Form1.resx rename to AirBomber/AirBomber/Properties/Resources.resx index 1af7de1..69274b7 100644 --- a/AirBomber/AirBomber/Form1.resx +++ b/AirBomber/AirBomber/Properties/Resources.resx @@ -117,4 +117,17 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\arrowDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\arrowUp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\arrowLeft.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\arrowRight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/AirBomber/AirBomber/Resources/arrowDown.png b/AirBomber/AirBomber/Resources/arrowDown.png new file mode 100644 index 0000000000000000000000000000000000000000..f527adfb14a9452d2786ae86dc5cebd086736812 GIT binary patch literal 1831 zcmeH||2I@=9LFzxG5NOcnM-XMY9up7qm39wnC2Qo#tcsRwiqFsPK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&?>JYmzkzv zQg~}T-;E4cZz0pdpMPAH9_5!0`To<(`}pC#H~9|_b?!cTZWa7%$}|}|qAmS{jsF64 CuI8Ws literal 0 HcmV?d00001 diff --git a/AirBomber/AirBomber/Resources/arrowRight.png b/AirBomber/AirBomber/Resources/arrowRight.png new file mode 100644 index 0000000000000000000000000000000000000000..08ca64dd3fdf7d39a0a15101b52b7c009b987e3d GIT binary patch literal 1920 zcmd5-3sVzU6b@|}1r-q$#kahzF1A<%jiG`YNeH0wR98gnP||7^jaMRADYZ={DuN1& zv;`#zFcyszBRj6IDdVGd5!l6NaJ4c+%Sraa*+0?g%-t{Ne&>AW+|A^EF|AC9 z8RI_1T_%%_QLFGonao824>9sRV1kodi{Qg$dtywq%+@+hgv|$8QSnhS*)PST-fVP* zz1vpRn(Z=~cYyS`s1yC4%48!Zs`04go$H-<*u$L>p311r!|#rTZC(91e>G;BFtW=# zH2h@P>YxJlMc!Li{8j&;tG>s3;J;k!Y+in-d8Gm$@q)1wZNK1}+4w7K1>w-Nn zHJvr;@KQ1@NWd8-lZ)7F{-&8Aty6LOs}j;(7%(Eg9;)9e|5VWLML~5$-;ur+#1>oS zm@rU?{<0EPC4Ju^b~|5LMCO`Motao4AmsK?W2|yFp|J>M9VZqZ=@StijNZ>K|&v5NAgY$J=#||h}a0;sia2-2qB2o^1F|bi@rgRtVHW< z!O%l>s0`tPK2Yql5D9_8bi}^0o-ZRS_MmVMJ5$ovi&)(H+E)mjBwp&$UtFKPX{<+O z$UnABg`%I}`2Fd5E%FMr`lX8yI$s>d>9}~tAX4|$FEf~c0(6$ML=sjKFs3ymeAAUb;sMDyyF zGEAmYguPN(S5Mq2`_V?OS*rzdhe>?mJ;2|_-cV&W@^N5ry3oA06zv$5fx{7p$YBT# zad6PbmnvY~8?6I~;+6^^Om09d2`3oFSRN;dQ=Wn3-iE_a(b-aBBR8JufQrAjkx)^Y z5SK#V^y+J!wh#ui5CHkjK(^-g}>=01R z`E___k9W@Exlq+`-NY?qj5k}0K)7Xl9`xGyt&bTbr+@H={L{m^(xxqbqNM+{GPqLu+@ue@M{)QH*{}4GK(Gr^V z67DlgsOKeI>kd-NcuRVj`rz@;}7Q-vn?5TmlnhUojY;uJ$nuah5f6kQ9S|(xDRS73Ud4Ng#t{wXr ze_c-AnB{0g8X1>wAwCasd@WKZOoJit1LuaVS#(0h!IK^DPpV70)~!Dm|LSD-riVA; zV(cqK>RjRAL?+YMy!#MYVbo^S5w)`%@o=GVxKN9d=BC=^aNUA);JSHmmzL2#EwyL! zn8h@>o5>93a;k}I<8_;zH6GGAIZ&# zrJn~mEF#s4%L_?|h zIwo@gSCv3-@pJfqCE;L610Qm&%jgTZJ&D8GOgRggZZ|GLMKAGnEE1`irku4*cO=&u zM?aYDxFJ&gI2hl6Q41b8)*N3=kT@9Qn?T1rMrqGQ=NEHFmOZ!{prYx)cV}*o|V-!M5ss qO-=h}j^6fwE{XXctUvFbe&-TZVrg{wzHTP`Ys%Eh1l$(AVb8zzTiBlf literal 0 HcmV?d00001 diff --git a/AirBomber/AirBomber/Resources/arrowUp.png b/AirBomber/AirBomber/Resources/arrowUp.png new file mode 100644 index 0000000000000000000000000000000000000000..20128d564b3b16d6d8204721d2bc72e41c4377f7 GIT binary patch literal 2681 zcmeH}`#aMM9LK*pnA`H`wycX1DMHv1c1Ug3DyGdPmrXin%_X-YavMwHRH(yIBuXP< zPW2>aZ84XV%fyuC;Y@_hx0A8Ct!c;k2hLCD{N{)E^LpOzA3x9M^L{?ro*r1J4qOKS z04VM_ng9T50jv5^Yu##M4*0CBLhTX(dlX>uw@X%yI@Q(P6#$;)>MDaZR=sxgalcCd zu*LKrso@AFQUK6dk3+k9C6NCb=({s~XbZY|MOC`c?wCVg@PB?j?dzoJz2);Ki*{G* zEcF@zE(r!{S7B<0|8IP1{4P7Df|4^jrfrrUs=CJSwQQW%Q<7-yFNDqGazJ^Cb`@er zr%I+({RM*%?qIGx6s(S}j(m z>f}D0a{~QmB-B|w1*g_ZZXw@z1)zw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489b66f737d41b754b3310cbcd192b4c43ed28 Mon Sep 17 00:00:00 2001 From: malimova Date: Sun, 1 Oct 2023 23:21:45 +0400 Subject: [PATCH 4/6] =?UTF-8?q?=D0=97=D0=B0=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=B0=20Dra?= =?UTF-8?q?wningAirBomber?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/DrawningAirBomber.cs | 243 +++++++++--------- AirBomber/AirBomber/EntityAirBomber.cs | 6 +- AirBomber/AirBomber/FormAirBomber.Designer.cs | 22 +- AirBomber/AirBomber/FormAirBomber.cs | 62 ++++- 4 files changed, 208 insertions(+), 125 deletions(-) diff --git a/AirBomber/AirBomber/DrawningAirBomber.cs b/AirBomber/AirBomber/DrawningAirBomber.cs index 69c74da..088096c 100644 --- a/AirBomber/AirBomber/DrawningAirBomber.cs +++ b/AirBomber/AirBomber/DrawningAirBomber.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -22,30 +23,23 @@ namespace AirBomber /// /// Ширина прорисовки бомбардировщика /// - private readonly int _bomberWidth = 110; + private readonly int _bomberWidth = 150; /// /// Высота прорисовки бомбардировщика /// - private readonly int _bomberHeight = 60; - /// - /// Инициализация свойств - /// - /// Скорость - /// Вес - /// Цвет кузова - /// Дополнительный цвет - /// Признак наличия бомб - /// Признак наличия топливных баков - /// Ширина картинки - /// Высота картинки + private readonly int _bomberHeight = 120; /// true - объект создан, false - проверка не пройдена, нельзя создать объект в этих размерах - public bool Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bombs, bool fuelTanks, int width, int height) + 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) + { + return false; + } EntityAirBomber = new EntityAirBomber(); - EntityAirBomber.Init(speed, weight, bodyColor, additionalColor, bombs, fuelTanks); + EntityAirBomber.Init(speed, weight, bodyColor, additionalColor, bombs, bombsColor, fuelTanks); return true; } /// @@ -55,7 +49,14 @@ namespace AirBomber /// Координата Y public void SetPosition(int x, int y) { - // TODO: Изменение x, y + if (x < 0 || x + _bomberWidth > _pictureWidth) + { + x = 15; + } + if (y < 0 || y + _bomberHeight > _pictureHeight) + { + y = 15; + } _startPosX = x; _startPosY = y; } @@ -71,140 +72,140 @@ namespace AirBomber } switch (direction) { - //влево case DirectionType.Left: if (_startPosX - EntityAirBomber.Step > 0) { _startPosX -= (int)EntityAirBomber.Step; } break; - //вверх case DirectionType.Up: if (_startPosY - EntityAirBomber.Step > 0) { _startPosY -= (int)EntityAirBomber.Step; } break; - // вправо case DirectionType.Right: - // TODO: Продумать логику + if (_startPosX + EntityAirBomber.Step + _bomberWidth < _pictureWidth) + { + _startPosX += (int)EntityAirBomber.Step; + } break; - //вниз case DirectionType.Down: - // TODO: Продумать логику + if (_startPosY + EntityAirBomber.Step + _bomberHeight < _pictureHeight) + { + _startPosY += (int)EntityAirBomber.Step; + } break; } } - /// - /// Прорисовка объекта - /// - /// - public void DrawTransport(Graphics g) + public void DrawBomber(Graphics g) { if (EntityAirBomber == null) { return; } Pen pen = new(Color.Black); - Brush additionalBrush = new - SolidBrush(EntityAirBomber.AdditionalColor); - // обвесы + Brush additionalBrush = new SolidBrush(EntityAirBomber.AdditionalColor); + Brush bodyColor = new SolidBrush(EntityAirBomber.BodyColor); + Brush bombsColor = new SolidBrush(EntityAirBomber.BombsColor); + Brush wingsColor = new SolidBrush(Color.DeepPink); + // bombs if (EntityAirBomber.Bombs) { - g.DrawEllipse(pen, _startPosX + 90, _startPosY, 20, 20); - g.DrawEllipse(pen, _startPosX + 90, _startPosY + 40, 20, - 20); - g.DrawRectangle(pen, _startPosX + 90, _startPosY + 10, - 20, 40); - g.DrawRectangle(pen, _startPosX + 90, _startPosY, 15, - 15); - g.DrawRectangle(pen, _startPosX + 90, _startPosY + 45, - 15, 15); - g.FillEllipse(additionalBrush, _startPosX + 90, - _startPosY, 20, 20); - g.FillEllipse(additionalBrush, _startPosX + 90, - _startPosY + 40, 20, 20); - g.FillRectangle(additionalBrush, _startPosX + 90, - _startPosY + 10, 20, 40); - g.FillRectangle(additionalBrush, _startPosX + 90, _startPosY + 1, 15, 15); - g.FillRectangle(additionalBrush, _startPosX + 90, - _startPosY + 45, 15, 15); - g.DrawEllipse(pen, _startPosX, _startPosY, 20, 20); - g.DrawEllipse(pen, _startPosX, _startPosY + 40, 20, 20); - g.DrawRectangle(pen, _startPosX, _startPosY + 10, 20, - 40); - g.DrawRectangle(pen, _startPosX + 5, _startPosY, 14, - 15); - g.DrawRectangle(pen, _startPosX + 5, _startPosY + 45, - 14, 15); - g.FillEllipse(additionalBrush, _startPosX, _startPosY, - 20, 20); - g.FillEllipse(additionalBrush, _startPosX, _startPosY + - 40, 20, 20); - g.FillRectangle(additionalBrush, _startPosX + 1, - _startPosY + 10, 25, 40); - g.FillRectangle(additionalBrush, _startPosX + 5, - _startPosY + 1, 15, 15); - g.FillRectangle(additionalBrush, _startPosX + 5, - _startPosY + 45, 15, 15); - g.DrawRectangle(pen, _startPosX + 35, _startPosY, 39, - 15); - g.DrawRectangle(pen, _startPosX + 35, _startPosY + 45, - 39, 15); - g.FillRectangle(additionalBrush, _startPosX + 35, - _startPosY + 1, 40, 15); - g.FillRectangle(additionalBrush, _startPosX + 35, - _startPosY + 45, 40, 15); + 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.DrawEllipse(pen, _startPosX + 10, _startPosY + 5, 20, 20); - g.DrawEllipse(pen, _startPosX + 10, _startPosY + 35, 20, 20); - g.DrawEllipse(pen, _startPosX + 80, _startPosY + 5, 20, 20); - g.DrawEllipse(pen, _startPosX + 80, _startPosY + 35, 20, 20); - g.DrawRectangle(pen, _startPosX + 9, _startPosY + 15, 10, 30); - g.DrawRectangle(pen, _startPosX + 90, _startPosY + 15, 10, - 30); - g.DrawRectangle(pen, _startPosX + 20, _startPosY + 4, 70, 52); - //задние фары - Brush brRed = new SolidBrush(Color.Red); - g.FillEllipse(brRed, _startPosX + 10, _startPosY + 5, 20, 20); - g.FillEllipse(brRed, _startPosX + 10, _startPosY + 35, 20, - 20); - //передние фары - Brush brYellow = new SolidBrush(Color.Yellow); - g.FillEllipse(brYellow, _startPosX + 80, _startPosY + 5, 20, - 20); - g.FillEllipse(brYellow, _startPosX + 80, _startPosY + 35, 20, - 20); - //кузов - Brush br = new SolidBrush(EntityAirBomber.BodyColor); - g.FillRectangle(br, _startPosX + 10, _startPosY + 15, 10, 30); - g.FillRectangle(br, _startPosX + 90, _startPosY + 15, 10, 30); - g.FillRectangle(br, _startPosX + 20, _startPosY + 5, 70, 50); - //стекла - Brush brBlue = new SolidBrush(Color.LightBlue); - g.FillRectangle(brBlue, _startPosX + 70, _startPosY + 10, 5, - 40); - g.FillRectangle(brBlue, _startPosX + 30, _startPosY + 10, 5, - 40); - g.FillRectangle(brBlue, _startPosX + 35, _startPosY + 8, 35, - 2); - g.FillRectangle(brBlue, _startPosX + 35, _startPosY + 51, 35, - 2); - //выделяем рамкой крышу - g.DrawRectangle(pen, _startPosX + 35, _startPosY + 10, 35, - 40); - g.DrawRectangle(pen, _startPosX + 75, _startPosY + 15, 25, - 30); - g.DrawRectangle(pen, _startPosX + 10, _startPosY + 15, 15, - 30); - // крыло + //границы бомбера + g.FillPolygon(additionalBrush, new Point[] //nose + { + new Point(_startPosX + 19, _startPosY + 50), + new Point(_startPosX + 19, _startPosY + 69), + new Point(_startPosX + 1, _startPosY + 59), + } + ); + g.FillRectangle(bodyColor, _startPosX + 20, _startPosY + 50, 120, 20); //korpus + g.FillPolygon(additionalBrush, new Point[] //up left wing + { + new Point(_startPosX + 36, _startPosY + 49), + new Point(_startPosX + 36, _startPosY + 1), + new Point(_startPosX + 45, _startPosY + 1), + new Point(_startPosX + 55, _startPosY + 49), + } + ); + g.FillPolygon(additionalBrush, new Point[] //down left wing + { + new Point(_startPosX + 36, _startPosY + 71), + new Point(_startPosX + 36, _startPosY + 116), + new Point(_startPosX + 45, _startPosY + 116), + new Point(_startPosX + 54, _startPosY + 71), + } + ); + g.FillPolygon(wingsColor, new Point[] //up right wing + { + new Point(_startPosX + 120, _startPosY + 49), + new Point(_startPosX + 120, _startPosY + 42), + new Point(_startPosX + 140, _startPosY + 7), + new Point(_startPosX + 140, _startPosY + 49), + } + ); + g.FillPolygon(wingsColor, new Point[] //down right wing + { + new Point(_startPosX + 120, _startPosY + 70), + new Point(_startPosX + 120, _startPosY + 77), + new Point(_startPosX + 140, _startPosY + 112), + new Point(_startPosX + 140, _startPosY + 70), + } + ); + + g.DrawPolygon(pen, new Point[] //nose + { + new Point(_startPosX + 20, _startPosY + 49), + new Point(_startPosX + 20, _startPosY + 70), + new Point(_startPosX, _startPosY + 59), + } + ); + g.DrawRectangle(pen, _startPosX + 19, _startPosY + 49, 121, 21); //корпус + g.DrawPolygon(pen, new Point[] //верхнее left крыло + { + new Point(_startPosX + 35, _startPosY + 49), + new Point(_startPosX + 35, _startPosY), + new Point(_startPosX + 45, _startPosY), + new Point(_startPosX + 55, _startPosY + 49), + } + ); + g.DrawPolygon(pen, new Point[] //нижнее left крыло + { + new Point(_startPosX + 36, _startPosY + 71), + new Point(_startPosX + 36, _startPosY + 116), + new Point(_startPosX + 45, _startPosY + 116), + new Point(_startPosX + 54, _startPosY + 71), + } + ); + g.DrawPolygon(pen, new Point[] //up right крыло + { + new Point(_startPosX + 120, _startPosY + 49), + new Point(_startPosX + 120, _startPosY + 42), + new Point(_startPosX + 140, _startPosY + 7), + new Point(_startPosX + 140, _startPosY + 49), + } + ); + g.DrawPolygon(pen, new Point[] //down right крыло + { + new Point(_startPosX + 120, _startPosY + 70), + new Point(_startPosX + 120, _startPosY + 77), + new Point(_startPosX + 140, _startPosY + 112), + new Point(_startPosX + 140, _startPosY + 70), + } + ); if (EntityAirBomber.FuelTanks) { - g.FillRectangle(additionalBrush, _startPosX, _startPosY - + 5, 10, 50); - g.DrawRectangle(pen, _startPosX, _startPosY + 5, 10, - 50); + g.FillRectangle(additionalBrush, _startPosX + 63, _startPosY + 34, 20, 15); + g.DrawRectangle(pen, _startPosX + 63, _startPosY + 34, 20, 15); + g.FillRectangle(additionalBrush, _startPosX + 63, _startPosY + 70, 20, 15); + g.DrawRectangle(pen, _startPosX + 63, _startPosY + 70, 20, 15); } } } diff --git a/AirBomber/AirBomber/EntityAirBomber.cs b/AirBomber/AirBomber/EntityAirBomber.cs index a4907a1..133015d 100644 --- a/AirBomber/AirBomber/EntityAirBomber.cs +++ b/AirBomber/AirBomber/EntityAirBomber.cs @@ -13,7 +13,8 @@ namespace AirBomber public double Weight { get; private set; } public Color BodyColor { get; private set; } public Color AdditionalColor { get; private set; } - public bool Bombs { get; private set; } + public bool Bombs { get; private set; } + public Color BombsColor { get; private set; } public bool FuelTanks { get; private set; } public double Step => (double)Speed * 100 / Weight; /// @@ -26,13 +27,14 @@ namespace AirBomber /// Признак наличия бомб /// Признак наличия топливных баков public void Init(int speed, double weight, Color bodyColor, Color - additionalColor, bool bombs, bool fuelTanks) + additionalColor, bool bombs, Color bombsColor, bool fuelTanks) { Speed = speed; Weight = weight; BodyColor = bodyColor; AdditionalColor = additionalColor; Bombs = bombs; + BombsColor = bombsColor; FuelTanks = fuelTanks; } diff --git a/AirBomber/AirBomber/FormAirBomber.Designer.cs b/AirBomber/AirBomber/FormAirBomber.Designer.cs index 6ad235b..5e931c9 100644 --- a/AirBomber/AirBomber/FormAirBomber.Designer.cs +++ b/AirBomber/AirBomber/FormAirBomber.Designer.cs @@ -33,6 +33,8 @@ buttonLeft = new Button(); buttonRight = new Button(); buttonUp = new Button(); + pictureBoxAirBomber = new PictureBox(); + ((System.ComponentModel.ISupportInitialize)pictureBoxAirBomber).BeginInit(); SuspendLayout(); // // buttonCreate @@ -44,6 +46,7 @@ buttonCreate.TabIndex = 0; buttonCreate.Text = "Создать"; buttonCreate.UseVisualStyleBackColor = true; + buttonCreate.Click += buttonCreate_Click; // // buttonDown // @@ -55,6 +58,7 @@ buttonDown.Size = new Size(30, 30); buttonDown.TabIndex = 1; buttonDown.UseVisualStyleBackColor = true; + buttonDown.Click += buttonMove_Click; // // buttonLeft // @@ -66,6 +70,7 @@ buttonLeft.Size = new Size(30, 30); buttonLeft.TabIndex = 2; buttonLeft.UseVisualStyleBackColor = true; + buttonLeft.Click += buttonMove_Click; // // buttonRight // @@ -77,6 +82,7 @@ buttonRight.Size = new Size(30, 30); buttonRight.TabIndex = 3; buttonRight.UseVisualStyleBackColor = true; + buttonRight.Click += buttonMove_Click; // // buttonUp // @@ -88,6 +94,17 @@ buttonUp.Size = new Size(30, 30); buttonUp.TabIndex = 4; buttonUp.UseVisualStyleBackColor = true; + buttonUp.Click += buttonMove_Click; + // + // pictureBoxAirBomber + // + pictureBoxAirBomber.BackColor = SystemColors.Control; + pictureBoxAirBomber.Dock = DockStyle.Fill; + pictureBoxAirBomber.Location = new Point(0, 0); + pictureBoxAirBomber.Name = "pictureBoxAirBomber"; + pictureBoxAirBomber.Size = new Size(986, 540); + pictureBoxAirBomber.TabIndex = 5; + pictureBoxAirBomber.TabStop = false; // // FormAirBomber // @@ -99,8 +116,10 @@ Controls.Add(buttonLeft); Controls.Add(buttonDown); Controls.Add(buttonCreate); + Controls.Add(pictureBoxAirBomber); Name = "FormAirBomber"; - Text = "Form1"; + Text = "Бомбардировщик"; + ((System.ComponentModel.ISupportInitialize)pictureBoxAirBomber).EndInit(); ResumeLayout(false); } @@ -111,5 +130,6 @@ private Button buttonLeft; private Button buttonRight; private Button buttonUp; + private PictureBox pictureBoxAirBomber; } } \ No newline at end of file diff --git a/AirBomber/AirBomber/FormAirBomber.cs b/AirBomber/AirBomber/FormAirBomber.cs index e998b26..b2b6357 100644 --- a/AirBomber/AirBomber/FormAirBomber.cs +++ b/AirBomber/AirBomber/FormAirBomber.cs @@ -1,10 +1,70 @@ -namespace AirBomber +namespace AirBomber { public partial class FormAirBomber : Form { + /// + /// Поле-объект для прорисовки объекта + /// + private DrawningAirBomber? _drawningAirBomber; + public FormAirBomber() { InitializeComponent(); } + private void Draw() + { + if (_drawningAirBomber == null) + { + return; + } + Bitmap bmp = new(pictureBoxAirBomber.Width, pictureBoxAirBomber.Height); + Graphics gr = Graphics.FromImage(bmp); + _drawningAirBomber.DrawBomber(gr); + pictureBoxAirBomber.Image = bmp; + } + /// + /// Обработка нажатия кнопки "Создать" + /// + /// + /// + private void buttonCreate_Click(object sender, EventArgs e) + { + Random random = new(); + _drawningAirBomber = new DrawningAirBomber(); + _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)); + Draw(); + } + /// + /// Изменение размеров формы + /// + /// + /// + private void buttonMove_Click(object sender, EventArgs e) + { + if (_drawningAirBomber == null) + { + return; + } + string name = ((Button)sender)?.Name ?? string.Empty; + switch (name) + { + case "buttonUp": + _drawningAirBomber.MoveTransport(DirectionType.Up); + break; + case "buttonDown": + _drawningAirBomber.MoveTransport(DirectionType.Down); + break; + case "buttonLeft": + _drawningAirBomber.MoveTransport(DirectionType.Left); + break; + case "buttonRight": + _drawningAirBomber.MoveTransport(DirectionType.Right); + break; + } + Draw(); + } } } \ No newline at end of file -- 2.25.1 From 6e1a5eb9c4f315bef2c52e61da9028a468212bc5 Mon Sep 17 00:00:00 2001 From: malimova Date: Mon, 2 Oct 2023 20:28:53 +0400 Subject: [PATCH 5/6] =?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. -- 2.25.1 From 393b97f07178fc1219b866b08c8ac1316fcf66b6 Mon Sep 17 00:00:00 2001 From: malimova Date: Mon, 2 Oct 2023 20:31:12 +0400 Subject: [PATCH 6/6] =?UTF-8?q?=D0=A7=D0=B8=D1=81=D1=82=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/DrawningAirBomber.cs | 12 ++++++------ AirBomber/AirBomber/EntityAirBomber.cs | 1 - 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/AirBomber/AirBomber/DrawningAirBomber.cs b/AirBomber/AirBomber/DrawningAirBomber.cs index c448135..b9decf0 100644 --- a/AirBomber/AirBomber/DrawningAirBomber.cs +++ b/AirBomber/AirBomber/DrawningAirBomber.cs @@ -104,7 +104,7 @@ namespace AirBomber new Point(_startPosX + 1, _startPosY + 59), } ); - g.FillRectangle(bodyColor, _startPosX + 20, _startPosY + 50, 120, 20); //korpus + g.FillRectangle(bodyColor, _startPosX + 20, _startPosY + 50, 120, 20); //body g.FillPolygon(additionalBrush, new Point[] //up left wing { new Point(_startPosX + 36, _startPosY + 49), @@ -145,8 +145,8 @@ namespace AirBomber new Point(_startPosX, _startPosY + 59), } ); - g.DrawRectangle(pen, _startPosX + 19, _startPosY + 49, 121, 21); //корпус - g.DrawPolygon(pen, new Point[] //верхнее left крыло + g.DrawRectangle(pen, _startPosX + 19, _startPosY + 49, 121, 21); //body + g.DrawPolygon(pen, new Point[] //up left wing { new Point(_startPosX + 35, _startPosY + 49), new Point(_startPosX + 35, _startPosY), @@ -154,7 +154,7 @@ namespace AirBomber new Point(_startPosX + 55, _startPosY + 49), } ); - g.DrawPolygon(pen, new Point[] //нижнее left крыло + g.DrawPolygon(pen, new Point[] //down left wing { new Point(_startPosX + 36, _startPosY + 71), new Point(_startPosX + 36, _startPosY + 116), @@ -162,7 +162,7 @@ namespace AirBomber new Point(_startPosX + 54, _startPosY + 71), } ); - g.DrawPolygon(pen, new Point[] //up right крыло + g.DrawPolygon(pen, new Point[] //up right wing { new Point(_startPosX + 120, _startPosY + 49), new Point(_startPosX + 120, _startPosY + 42), @@ -170,7 +170,7 @@ namespace AirBomber new Point(_startPosX + 140, _startPosY + 49), } ); - g.DrawPolygon(pen, new Point[] //down right крыло + g.DrawPolygon(pen, new Point[] //down right wing { new Point(_startPosX + 120, _startPosY + 70), new Point(_startPosX + 120, _startPosY + 77), diff --git a/AirBomber/AirBomber/EntityAirBomber.cs b/AirBomber/AirBomber/EntityAirBomber.cs index 1a7de6d..051adc5 100644 --- a/AirBomber/AirBomber/EntityAirBomber.cs +++ b/AirBomber/AirBomber/EntityAirBomber.cs @@ -27,6 +27,5 @@ namespace AirBomber BombsColor = bombsColor; FuelTanks = fuelTanks; } - } } -- 2.25.1