From 4693f2b5513e1a5014c3d63385f865ba6dcd5808 Mon Sep 17 00:00:00 2001 From: elizaveta Date: Wed, 13 Mar 2024 00:33:53 +0400 Subject: [PATCH 1/6] commit --- Tank/Tank/DirectionType.cs | 27 ++++++ Tank/Tank/DrawningtTank.cs | 150 +++++++++++++++++++++++++++++++++ Tank/Tank/EntityTank.cs | 57 +++++++++++++ Tank/Tank/FormTank.Designer.cs | 22 +++-- Tank/Tank/FormTank.cs | 12 ++- Tank/Tank/FormTank.resx | 50 +++++------ 6 files changed, 284 insertions(+), 34 deletions(-) create mode 100644 Tank/Tank/DirectionType.cs create mode 100644 Tank/Tank/DrawningtTank.cs create mode 100644 Tank/Tank/EntityTank.cs diff --git a/Tank/Tank/DirectionType.cs b/Tank/Tank/DirectionType.cs new file mode 100644 index 0000000..8923629 --- /dev/null +++ b/Tank/Tank/DirectionType.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tank; + +public enum DirectionType +{ + /// + /// Вверх + /// + Up = 1, + /// + /// Вниз + /// + Down = 2, + /// + /// Влево + /// + Left = 3, + /// + /// Вправо + /// + Right = 4 +} diff --git a/Tank/Tank/DrawningtTank.cs b/Tank/Tank/DrawningtTank.cs new file mode 100644 index 0000000..dead204 --- /dev/null +++ b/Tank/Tank/DrawningtTank.cs @@ -0,0 +1,150 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tank; + +public class DrawningtTank +{ + /// + /// Класс-сущность + /// + public EntityTank? EntityTank { get; private set; } + /// + /// Ширина окна + /// + private int? _pictureWidth; + /// + /// Высота окна + /// + private int? _pictureHeight; + /// + /// Левая координата прорисовки автомобиля + /// + private int? _startPosX; + /// + /// Верхняя кооридната прорисовки автомобиля + /// + private int? _startPosY; + /// + /// Ширина прорисовки автомобиля + /// + private readonly int _drawningCarWidth = 110; + /// + /// Высота прорисовки автомобиля + /// + private readonly int _drawningCarHeight = 60; + /// + /// Инициализация свойств + /// + /// Скорость + /// Вес + /// Основной цвет + /// Дополнительный цвет + /// Признак наличия обвеса + /// Признак наличия антикрыла + /// Признак наличия гоночной полосы + public void Init(int speed, double weight, Color bodyColor, Color + additionalColor, bool bodyKit, bool wing, bool sportLine) + { + EntityTank = new EntityTank(); + EntityTank.Init(speed, weight, bodyColor, additionalColor, + bodyKit, wing, sportLine); + _pictureWidth = null; + _pictureHeight = null; + _startPosX = null; + _startPosY = null; + } + /// + /// Установка границ поля + /// + /// Ширина поля + /// Высота поля + /// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах +public bool SetPictureSize(int width, int height) + { + // TODO проверка, что объект "влезает" в размеры поля + // если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена + _pictureWidth = width; + _pictureHeight = height; + return true; + } + /// + /// Установка позиции + /// + /// Координата X + /// Координата Y + public void SetPosition(int x, int y) + { + if (!_pictureHeight.HasValue || !_pictureWidth.HasValue) + { + return; + } + // TODO если при установке объекта в эти координаты, он будет "выходить" за границы формы + // то надо изменить координаты, чтобы он оставался в этих границах + _startPosX = x; + _startPosY = y; + } + /// + /// Изменение направления перемещения + /// + /// Направление + /// true - перемещене выполнено, false - перемещение невозможно +public bool MoveTransport(DirectionType direction) + { + if (EntityTank == null || !_startPosX.HasValue || + !_startPosY.HasValue) + { + return false; + } + switch (direction) + { + //влево + case DirectionType.Left: + if (_startPosX.Value - EntityTank.Step > 0) + { + _startPosX -= (int)EntityTank.Step; + } + return true; + //вверх + case DirectionType.Up: + if (_startPosY.Value - EntityTank.Step > 0) + { + _startPosY -= (int)EntityTank.Step; + } + return true; + // вправо + case DirectionType.Right: + //TODO прописать логику сдвига в право + return true; + //вниз + case DirectionType.Down: + //TODO прописать логику сдвига в вниз + return true; + default: + return false; + } + } + /// + /// Прорисовка объекта + /// + /// + public void DrawTransport(Graphics g) + { + if (EntityTank == null || !_startPosX.HasValue || + !_startPosY.HasValue) + { + return; + } + Pen pen = new(Color.Black); + Brush additionalBrush = new + SolidBrush(EntityTank.AdditionalColor); + // обвесы + if (EntityTank.BodyKit) + { + return; + } + } +} diff --git a/Tank/Tank/EntityTank.cs b/Tank/Tank/EntityTank.cs new file mode 100644 index 0000000..f3512d3 --- /dev/null +++ b/Tank/Tank/EntityTank.cs @@ -0,0 +1,57 @@ +namespace Tank; + +public class EntityTank +{ + /// + /// Скорость + /// + 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 BodyKit { get; private set; } + /// + /// Признак (опция) наличия антикрыла + /// + public bool Wing { get; private set; } + /// + /// Признак (опция) наличия гоночной полосы + /// + public bool SportLine { get; private set; } + /// + /// Шаг перемещения автомобиля + /// + public double Step => Speed * 100 / Weight; + /// + /// Инициализация полей объекта-класса спортивного автомобиля + /// + /// Скорость + /// Вес автомобиля + /// Основной цвет + /// Дополнительный цвет + /// Признак наличия обвеса + /// Признак наличия антикрыла + /// Признак наличия гоночной полосы + public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool wing, bool sportLine) + { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + AdditionalColor = additionalColor; + BodyKit = bodyKit; + Wing = wing; + SportLine = sportLine; + } +} \ No newline at end of file diff --git a/Tank/Tank/FormTank.Designer.cs b/Tank/Tank/FormTank.Designer.cs index 5a22010..0cf2118 100644 --- a/Tank/Tank/FormTank.Designer.cs +++ b/Tank/Tank/FormTank.Designer.cs @@ -3,12 +3,12 @@ partial class FormTank { /// - /// Required designer variable. + /// Required designer variable. /// private System.ComponentModel.IContainer components = null; /// - /// Clean up any resources being used. + /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) @@ -23,15 +23,21 @@ #region Windows Form Designer generated code /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. + /// 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"; + SuspendLayout(); + // + // FormTank + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Name = "FormTank"; + Text = "Танк"; + ResumeLayout(false); } #endregion diff --git a/Tank/Tank/FormTank.cs b/Tank/Tank/FormTank.cs index 19f5b27..d9a07a7 100644 --- a/Tank/Tank/FormTank.cs +++ b/Tank/Tank/FormTank.cs @@ -1,3 +1,13 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + namespace Tank { public partial class FormTank : Form @@ -7,4 +17,4 @@ namespace Tank InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/Tank/Tank/FormTank.resx b/Tank/Tank/FormTank.resx index 1af7de1..af32865 100644 --- a/Tank/Tank/FormTank.resx +++ b/Tank/Tank/FormTank.resx @@ -1,17 +1,17 @@  - -- 2.25.1 From 0ed1f29f97f839d1301f8c05b23467d14d1fc57e Mon Sep 17 00:00:00 2001 From: elizaveta Date: Wed, 13 Mar 2024 00:39:20 +0400 Subject: [PATCH 2/6] f --- Tank/Tank/FormTank.Designer.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Tank/Tank/FormTank.Designer.cs b/Tank/Tank/FormTank.Designer.cs index 0cf2118..90da2fa 100644 --- a/Tank/Tank/FormTank.Designer.cs +++ b/Tank/Tank/FormTank.Designer.cs @@ -28,18 +28,31 @@ /// private void InitializeComponent() { + button1 = new Button(); SuspendLayout(); // + // button1 + // + button1.Location = new Point(51, 65); + button1.Name = "button1"; + button1.Size = new Size(150, 46); + button1.TabIndex = 0; + button1.Text = "button1"; + button1.UseVisualStyleBackColor = true; + // // FormTank // AutoScaleDimensions = new SizeF(13F, 32F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(800, 450); + Controls.Add(button1); Name = "FormTank"; Text = "Танк"; ResumeLayout(false); } #endregion + + private Button button1; } } \ No newline at end of file -- 2.25.1 From 3a7a9170a6f9720b35c6d39166287e937bccb0ee Mon Sep 17 00:00:00 2001 From: elizaveta Date: Wed, 13 Mar 2024 03:07:19 +0400 Subject: [PATCH 3/6] commit --- .../{DrawningtTank.cs => DrawningTank.cs} | 102 ++++++++++---- Tank/Tank/EntityTank.cs | 20 ++- Tank/Tank/FormTank.Designer.cs | 103 ++++++++++++-- Tank/Tank/FormTank.cs | 83 +++++++++++ Tank/Tank/Properties/Resources.Designer.cs | 103 ++++++++++++++ Tank/Tank/Properties/Resources.resx | 133 ++++++++++++++++++ Tank/Tank/Resources/down.png | Bin 0 -> 1474 bytes Tank/Tank/Resources/left.png | Bin 0 -> 1486 bytes Tank/Tank/Resources/right.png | Bin 0 -> 1408 bytes Tank/Tank/Resources/up.png | Bin 0 -> 1437 bytes Tank/Tank/Tank.csproj | 15 ++ 11 files changed, 505 insertions(+), 54 deletions(-) rename Tank/Tank/{DrawningtTank.cs => DrawningTank.cs} (51%) create mode 100644 Tank/Tank/Properties/Resources.Designer.cs create mode 100644 Tank/Tank/Properties/Resources.resx create mode 100644 Tank/Tank/Resources/down.png create mode 100644 Tank/Tank/Resources/left.png create mode 100644 Tank/Tank/Resources/right.png create mode 100644 Tank/Tank/Resources/up.png diff --git a/Tank/Tank/DrawningtTank.cs b/Tank/Tank/DrawningTank.cs similarity index 51% rename from Tank/Tank/DrawningtTank.cs rename to Tank/Tank/DrawningTank.cs index dead204..70c7430 100644 --- a/Tank/Tank/DrawningtTank.cs +++ b/Tank/Tank/DrawningTank.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace Tank; -public class DrawningtTank +public class DrawningTank { /// /// Класс-сущность @@ -31,11 +31,11 @@ public class DrawningtTank /// /// Ширина прорисовки автомобиля /// - private readonly int _drawningCarWidth = 110; + private readonly int _drawningTankWidth = 145; /// /// Высота прорисовки автомобиля /// - private readonly int _drawningCarHeight = 60; + private readonly int _drawningTankHeight = 105; /// /// Инициализация свойств /// @@ -43,15 +43,13 @@ public class DrawningtTank /// Вес /// Основной цвет /// Дополнительный цвет - /// Признак наличия обвеса - /// Признак наличия антикрыла - /// Признак наличия гоночной полосы - public void Init(int speed, double weight, Color bodyColor, Color - additionalColor, bool bodyKit, bool wing, bool sportLine) + /// Признак наличия обвеса + /// Признак наличия антикрыла + + public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool pushka, bool pulemet) { EntityTank = new EntityTank(); - EntityTank.Init(speed, weight, bodyColor, additionalColor, - bodyKit, wing, sportLine); + EntityTank.Init(speed, weight, bodyColor, additionalColor,pushka, pulemet); _pictureWidth = null; _pictureHeight = null; _startPosX = null; @@ -63,13 +61,33 @@ public class DrawningtTank /// Ширина поля /// Высота поля /// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах -public bool SetPictureSize(int width, int height) + /// + /// Установка границ поля + /// + /// Ширина поля + /// Высота поля + /// true - границы заданы, false - проверка не пройдена, нельзя + public bool SetPictureSize(int width, int height) { - // TODO проверка, что объект "влезает" в размеры поля - // если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена - _pictureWidth = width; - _pictureHeight = height; - return true; + if (_drawningTankWidth <= width && _drawningTankHeight <= height) + { + _pictureWidth = width; + _pictureHeight = height; + if (_startPosX.HasValue && _startPosY.HasValue) + { + if (_startPosX + _drawningTankWidth > _pictureWidth) + { + _startPosX = _pictureWidth - _drawningTankWidth; + } + + if (_startPosY + _drawningTankHeight > _pictureHeight) + { + _startPosY = _pictureHeight - _drawningTankHeight; + } + } + return true; + } + return false; } /// /// Установка позиции @@ -82,8 +100,11 @@ public bool SetPictureSize(int width, int height) { return; } - // TODO если при установке объекта в эти координаты, он будет "выходить" за границы формы - // то надо изменить координаты, чтобы он оставался в этих границах + if (x < 0) x = 0; + else if (x + _drawningTankWidth > _pictureWidth) x = _pictureWidth.Value - _drawningTankWidth; + + if (y < 0) y = 0; + else if (y + _drawningTankHeight > _pictureHeight) y = _pictureHeight.Value - _drawningTankHeight; _startPosX = x; _startPosY = y; } @@ -92,7 +113,7 @@ public bool SetPictureSize(int width, int height) /// /// Направление /// true - перемещене выполнено, false - перемещение невозможно -public bool MoveTransport(DirectionType direction) + public bool MoveTransport(DirectionType direction) { if (EntityTank == null || !_startPosX.HasValue || !_startPosY.HasValue) @@ -104,24 +125,22 @@ public bool MoveTransport(DirectionType direction) //влево case DirectionType.Left: if (_startPosX.Value - EntityTank.Step > 0) - { _startPosX -= (int)EntityTank.Step; - } return true; //вверх case DirectionType.Up: if (_startPosY.Value - EntityTank.Step > 0) - { _startPosY -= (int)EntityTank.Step; - } return true; // вправо case DirectionType.Right: - //TODO прописать логику сдвига в право + if (_startPosX.Value + _drawningTankWidth + EntityTank.Step < _pictureWidth) + _startPosX += (int)EntityTank.Step; return true; //вниз case DirectionType.Down: - //TODO прописать логику сдвига в вниз + if (_startPosY.Value + _drawningTankHeight + EntityTank.Step < _pictureHeight) + _startPosY += (int)EntityTank.Step; return true; default: return false; @@ -139,12 +158,35 @@ public bool MoveTransport(DirectionType direction) return; } Pen pen = new(Color.Black); - Brush additionalBrush = new - SolidBrush(EntityTank.AdditionalColor); - // обвесы - if (EntityTank.BodyKit) + Brush additionalBrush = new SolidBrush(EntityTank.AdditionalColor); + Brush bodyBrush = new SolidBrush(EntityTank.BodyColor); + + g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 45, 150, 60); + g.DrawEllipse(pen, _startPosX.Value + 5, _startPosY.Value + 60, 33, 33); + g.DrawEllipse(pen, _startPosX.Value + 110, _startPosY.Value + 60, 33, 33); + g.DrawEllipse(pen, _startPosX.Value + 35, _startPosY.Value + 80, 16, 16); + g.DrawEllipse(pen, _startPosX.Value + 55, _startPosY.Value + 83, 16, 16); + g.DrawEllipse(pen, _startPosX.Value + 75, _startPosY.Value + 83, 16, 16); + g.DrawEllipse(pen, _startPosX.Value + 95, _startPosY.Value + 80, 16, 16); + + g.FillEllipse(bodyBrush, _startPosX.Value + 45, _startPosY.Value + 55, 15, 15); + g.FillEllipse(bodyBrush, _startPosX.Value + 65, _startPosY.Value + 55, 15, 15); + g.FillEllipse(bodyBrush, _startPosX.Value + 85, _startPosY.Value + 55, 15, 15); + + g.FillRectangle(bodyBrush, _startPosX.Value + 30, _startPosY.Value + 10, 100, 30); + g.FillRectangle(bodyBrush, _startPosX.Value + 5, _startPosY.Value + 40, 140, 25); + + if(EntityTank.Pushka) + g.FillRectangle(additionalBrush, _startPosX.Value + 120, _startPosY.Value + 20, 100, 15); + + if (EntityTank.Pulemet) { - return; + Point p = new Point(_startPosX.Value + 75, _startPosY.Value + 10); + Point p1 = new Point(_startPosX.Value + 80, _startPosY.Value + 1); + Point p2 = new Point(_startPosX.Value + 87, _startPosY.Value + 2); + Point p3 = new Point(_startPosX.Value + 80, _startPosY.Value + 10); + Point[] p_pulemet = { p, p1, p2, p3 }; + g.FillPolygon(additionalBrush, p_pulemet); } } } diff --git a/Tank/Tank/EntityTank.cs b/Tank/Tank/EntityTank.cs index f3512d3..39a4618 100644 --- a/Tank/Tank/EntityTank.cs +++ b/Tank/Tank/EntityTank.cs @@ -21,15 +21,11 @@ public class EntityTank /// /// Признак (опция) наличия обвеса /// - public bool BodyKit { get; private set; } + public bool Pushka { get; private set; } /// /// Признак (опция) наличия антикрыла /// - public bool Wing { get; private set; } - /// - /// Признак (опция) наличия гоночной полосы - /// - public bool SportLine { get; private set; } + public bool Pulemet { get; private set; } /// /// Шаг перемещения автомобиля /// @@ -41,17 +37,17 @@ public class EntityTank /// Вес автомобиля /// Основной цвет /// Дополнительный цвет - /// Признак наличия обвеса - /// Признак наличия антикрыла + /// Признак наличия обвеса + /// Признак наличия антикрыла /// Признак наличия гоночной полосы - public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool wing, bool sportLine) + public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool pushka, bool pulemet) { Speed = speed; Weight = weight; BodyColor = bodyColor; AdditionalColor = additionalColor; - BodyKit = bodyKit; - Wing = wing; - SportLine = sportLine; + Pushka = pushka; + Pulemet = pulemet; + } } \ No newline at end of file diff --git a/Tank/Tank/FormTank.Designer.cs b/Tank/Tank/FormTank.Designer.cs index 90da2fa..ef5db72 100644 --- a/Tank/Tank/FormTank.Designer.cs +++ b/Tank/Tank/FormTank.Designer.cs @@ -28,31 +28,110 @@ /// private void InitializeComponent() { - button1 = new Button(); + pictureBoxTank = new PictureBox(); + buttonCreate = new Button(); + buttonLeft = new Button(); + buttonUp = new Button(); + buttonRight = new Button(); + buttonDown = new Button(); + ((System.ComponentModel.ISupportInitialize)pictureBoxTank).BeginInit(); SuspendLayout(); // - // button1 + // pictureBoxTank // - button1.Location = new Point(51, 65); - button1.Name = "button1"; - button1.Size = new Size(150, 46); - button1.TabIndex = 0; - button1.Text = "button1"; - button1.UseVisualStyleBackColor = true; + pictureBoxTank.AccessibleRole = AccessibleRole.None; + pictureBoxTank.Dock = DockStyle.Fill; + pictureBoxTank.Location = new Point(0, 0); + pictureBoxTank.Name = "pictureBoxTank"; + pictureBoxTank.Size = new Size(1235, 854); + pictureBoxTank.SizeMode = PictureBoxSizeMode.AutoSize; + pictureBoxTank.TabIndex = 1; + pictureBoxTank.TabStop = false; + pictureBoxTank.Click += ButtonMove_Click; + // + // buttonCreate + // + buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonCreate.Location = new Point(12, 796); + buttonCreate.Name = "buttonCreate"; + buttonCreate.Size = new Size(150, 46); + buttonCreate.TabIndex = 2; + buttonCreate.Text = "Создать"; + buttonCreate.UseVisualStyleBackColor = true; + buttonCreate.Click += ButtonCreateTank_Click; + // + // buttonLeft + // + buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonLeft.BackgroundImage = Properties.Resources.left; + buttonLeft.BackgroundImageLayout = ImageLayout.Stretch; + buttonLeft.Location = new Point(1021, 786); + buttonLeft.Name = "buttonLeft"; + buttonLeft.Size = new Size(45, 45); + buttonLeft.TabIndex = 3; + buttonLeft.UseVisualStyleBackColor = true; + buttonLeft.Click += ButtonMove_Click; + // + // buttonUp + // + buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonUp.BackgroundImage = Properties.Resources.up; + buttonUp.BackgroundImageLayout = ImageLayout.Stretch; + buttonUp.Location = new Point(1072, 735); + buttonUp.Name = "buttonUp"; + buttonUp.Size = new Size(45, 45); + buttonUp.TabIndex = 4; + buttonUp.UseVisualStyleBackColor = true; + buttonUp.Click += ButtonMove_Click; + // + // buttonRight + // + buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonRight.BackgroundImage = Properties.Resources.right; + buttonRight.BackgroundImageLayout = ImageLayout.Stretch; + buttonRight.Location = new Point(1123, 786); + buttonRight.Name = "buttonRight"; + buttonRight.Size = new Size(45, 45); + buttonRight.TabIndex = 5; + buttonRight.UseVisualStyleBackColor = true; + buttonRight.Click += ButtonMove_Click; + // + // buttonDown + // + buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonDown.BackgroundImage = Properties.Resources.down; + buttonDown.BackgroundImageLayout = ImageLayout.Stretch; + buttonDown.Location = new Point(1072, 786); + buttonDown.Name = "buttonDown"; + buttonDown.Size = new Size(45, 45); + buttonDown.TabIndex = 6; + buttonDown.UseVisualStyleBackColor = true; + buttonDown.Click += ButtonMove_Click; // // FormTank // AutoScaleDimensions = new SizeF(13F, 32F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(800, 450); - Controls.Add(button1); + ClientSize = new Size(1235, 854); + Controls.Add(buttonDown); + Controls.Add(buttonRight); + Controls.Add(buttonUp); + Controls.Add(buttonLeft); + Controls.Add(buttonCreate); + Controls.Add(pictureBoxTank); Name = "FormTank"; Text = "Танк"; + ((System.ComponentModel.ISupportInitialize)pictureBoxTank).EndInit(); ResumeLayout(false); + PerformLayout(); } #endregion - - private Button button1; + private PictureBox pictureBoxTank; + private Button buttonCreate; + private Button buttonLeft; + private Button buttonUp; + private Button buttonRight; + private Button buttonDown; } } \ No newline at end of file diff --git a/Tank/Tank/FormTank.cs b/Tank/Tank/FormTank.cs index d9a07a7..f92df8d 100644 --- a/Tank/Tank/FormTank.cs +++ b/Tank/Tank/FormTank.cs @@ -12,9 +12,92 @@ namespace Tank { public partial class FormTank : Form { + /// + /// Поле-объект для прорисовки объекта + /// + private DrawningTank? _drawningTank; + /// + /// Конструктор формы + /// public FormTank() { InitializeComponent(); } + /// + /// Метод прорисовки машины + /// + private void Draw() + { + if (_drawningTank == null) + { + return; + } + Bitmap bmp = new(pictureBoxTank.Width, + pictureBoxTank.Height); + Graphics gr = Graphics.FromImage(bmp); + _drawningTank.DrawTransport(gr); + pictureBoxTank.Image = bmp; + } + /// + /// Обработка нажатия кнопки "Создать" + /// + /// + /// + private void ButtonCreateTank_Click(object sender, EventArgs e) + { + Random random = new(); + _drawningTank = new DrawningTank(); + + _drawningTank.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)), + Convert.ToBoolean(random.Next(0, 2))); + _drawningTank.SetPictureSize(pictureBoxTank.Width, + pictureBoxTank.Height); + _drawningTank.SetPosition(random.Next(10, 100), random.Next(10, + 100)); + Draw(); + } + /// + /// Перемещение объекта по форме (нажатие кнопок навигации) + /// + /// + /// + private void ButtonMove_Click(object sender, EventArgs e) + { + if (_drawningTank == null) + { + return; + } + string name = ((Button)sender)?.Name ?? string.Empty; + bool result = false; + switch (name) + { + case "buttonUp": + result = + _drawningTank.MoveTransport(DirectionType.Up); + break; + case "buttonDown": + result = + _drawningTank.MoveTransport(DirectionType.Down); + break; + case "buttonLeft": + result = + _drawningTank.MoveTransport(DirectionType.Left); + break; + case "buttonRight": + result = + _drawningTank.MoveTransport(DirectionType.Right); + break; + } + if (result) + { + Draw(); + } + } } } diff --git a/Tank/Tank/Properties/Resources.Designer.cs b/Tank/Tank/Properties/Resources.Designer.cs new file mode 100644 index 0000000..adfd17a --- /dev/null +++ b/Tank/Tank/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace Tank.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("Tank.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 down { + get { + object obj = ResourceManager.GetObject("down", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap left { + get { + object obj = ResourceManager.GetObject("left", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap right { + get { + object obj = ResourceManager.GetObject("right", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap up { + get { + object obj = ResourceManager.GetObject("up", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/Tank/Tank/Properties/Resources.resx b/Tank/Tank/Properties/Resources.resx new file mode 100644 index 0000000..02616cd --- /dev/null +++ b/Tank/Tank/Properties/Resources.resx @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + ..\Resources\left.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\down.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\right.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\up.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/Tank/Tank/Resources/down.png b/Tank/Tank/Resources/down.png new file mode 100644 index 0000000000000000000000000000000000000000..2a4910d13a56c9ef92d5c59767d3017596ac2dfa GIT binary patch literal 1474 zcmcIk`BTz)82%urC@5igR9=~9OXi8^Vi2Aox*mx;=CxT)tA$z~N$XLHimhj*Z64LO zn3-v|O^O-$_1M&8D>Ka_wPw}K0420QS=yQYgneh8_j%rT=6Qa63Il208tU8C0RS4l zK9nE@XMY7!MX@1b%%Fl`DM8+3&^)Zas5lTuN&X}NT1!x}7-hw+#_$PG0YDS_3RwS% zhQk0Thxt-SA?cCJQ~vQ0p?ZBH(>?ZAd$bU2--v<&WKIs#k}LykQiC2vHdbJbOFDr) z`NIO)QfIQT;lX>Ft_rTnq=3*dfXE$hL_Ni6TZP7IbrkoUY$!*wgW8?+ZRvx@{>e{n-s^s*;R>oqWm$x@pDwT#2oSd@ME|p`?fCC2( zY|YHf#H4Yjw9)S)BQEzH6U$rDrSu8p((|#gv14uHvXhC4%lr=|bGSsXZsn0*w-RPk zd@1QPp8I3F0VU0luQ@OL(6Y7J(`*3zGe2+iI7-HK?sVY>aR-s2yj1Q+l53iR9Q}k!>CofHL-YPWQ4?d@!2(kO%8$Kt*yHXmmTqJenfn<_}$RZ&^w7l(#v?- z8Lz|(*jycpF zcdk~=EiRYql$e+(aw;&d{zWC8@SE)A@g|7#cGk8k&K0=lO&e-nkK3@V(yV{A^zsznFFo_gJCN$kIPO`=ea1)T=^f~ z$y48@$He3q4U6?h_tPy}%v+D6rOp>a=E2fhR?{H8F8UBXD#~bmx+eop@0G--ntR!1 zAMF;&2c!YK#28(!4n!>NgbA;|?zxZoPj=>gic7UrIm0?-?WRxth$-eRfvy>;&eHIv za_gK^6IUpZmy9n)CqL5Y(S4A+jMI5kKgLT#l*}6tH9lnm=2b!K?dWC6UZ1JRZfci$ ze>++m%%XldyR3$9t7E1>~vjE2_ukVe0(UvT>xV ze%pu_bbwVZxst%#?FfPptf2S8n_}RDMc)w52Ae7Tf88jb4USU?J)by;9J-)c zw;Pj9Z1SK%;m!LBoA@Px+2{z84N12l&TF_a2RlM!+F^kUo7W?JLIv+k zmFyvlU|8TBwrV@E8kMbeo;N9cau`(75$3FbBk+2PiH#f6&H#8C<}A)ud6` zTkLEHNbF?E`LyBMg(ypv6TOmDXPQ?zY>UZ*9TT4T>2a}52b~|gu6y^zJ<}avXRgkD ze(U4{f0n`3Lb zg?r;Ti>@OzAW_+7eThYNk9U290TDYU@lTNvp!3 zKFqI06^Vm z4>bVpoVAHofveCZst0a}!~k!1P}7H>fB+do*+&830bflKr3|qub5C$002;!ziRfnB zI|_huv=5aMcsfGsj9WWNIl7yRqWDG}Wn0H{tViPsW^dDU(V5 z)OM_&L@Mx;_G+*HKFVr}TlE}Cq%GcTy=3H9wMkLRlU9C2Xnx#&<8x<#Tt`e3@3{9H zZP~V`&AYa`e6}=do>Y{P(@bhV*|~1`Cz}O8pJ$aM2u_F?VSXvx5Z|2uw_+X}Sya=< zP~^ARibLuV9W$E68Jv(_hN8W)LGt5O#K2fPKctTlX21e+5fRsRqtRLH9)KX?T`1cS z|IGCGm;rod>L7|EjPw&jLSH`tkkg$@upo!AKM4}@3)TSNmNAIr2y4A`AyKK54#siIH`ODs zeK1zxXv{xjj8(bIVzJ)c-Z84waYqrb;(m*Y8=Xpd66w#d>+*#THvR;3x7IJWYkW@{ zL+|^ExuWsdyF;nIlCDA*wYaob}iW6sIPw;Q~DE&GZwVIQ18QSfbvsQmo=$N`zV^$3ET z&X^4f3aWiOJiHhxaX3`JjyWF@z7>ZxekFTc1s`gTvCG)?etu%GI><3mQFt-)Bl?cn z!CIV+#b@F|hCkG61MKRF2L1sEuag`dF-BQUOh8nO42~oFhVL}#Xe)Le{s^kFl{jOJ zB2mmh(0h^~1K@Ut%p2-{WViGgx{$gjZ_u;LPdNVTxhHGW4*7p(3(qjKzOvqHtQ z*9zd;3Y%89?)8_JBX3NDe!+=b5djzs%1!#Ebyqme+AoD8w8|XF#pQxGf?L{0v_a{TUi}R$L~Cv;XM$n*Y*TERiCYn|U<&-}B(5Fu-J3-Nb!sn!=lR8@2bKI-K($jd zR#OnaoL5;v)ZnCVK+RmJ3X3eDOGWND@IX1^qP65_TSWM>lf zF;G3~k;@n_=U{V$57V56o+7l+orba98p^i&OeA&buLGv)Sh1{f8C^G;Eebbjt!eJ|-q6NRmx<+H{d{ z4}QOvp^292o~MOKX#HoWY(;kZzl^YauR>*r{}Rz2^wZ}plM-IW0i*~05?*ilbkoRk zprmYmmwm+TZD}W)OSrGd_A4!J?j2h$&WKp(nZ=1^X@_O1-RuPu!=-n-0hcgi$ph$f z9elcyDNbpQi{a4GZ!q>Sz_fg^7Pv%TXNu!a!hhAN6=*XLsiK{=;V>~m3)^|5L=#ef_?kh=%CcZh8y0}jI!7SiZT_!5zUJXwPkFSgY4VG$z%jVOcyqB*?AHDuT-k6sTD{CrEIb}H6t>{wz zTqbFJub7}m*4sLd#5ayUFT)pGN2c1KHn(0_S}oG~-sIMo#l=lTR+F3Rrqc`uVGjmA Lp8nJtcRKffQhte* literal 0 HcmV?d00001 diff --git a/Tank/Tank/Resources/right.png b/Tank/Tank/Resources/right.png new file mode 100644 index 0000000000000000000000000000000000000000..980696deb78e4eeb7453218a0582787fe689d1c1 GIT binary patch literal 1408 zcmX|>dpOf;0LOpZ3{4De?qfL!$>mfojfF^aoNc)`vlcnYDpop1!xo<9QaVT%%Jo6d zj!QlEu!GD|a<&t>v`#KHQ4w=zi^}==r}uf@@B4k9_xpL@Ki=p0W|N72ng}BV005eV zV?Kf4%GsXks-Sk`Pe}j(?nm(P3TBnc$KT}!$Cx}{Qn)epV=Z-caJWbxJr!dZuAdg{ z?;Yr`r#f&yF=p6ITLqmHsS-61>7_dyqjSysC8@~_h052zgr*&%%QJmgyDPgN*X9x` zUtI3b|CHS4*3YKNo;6(ROO|bZoSVzT!_0pSU19Y+eE5aI5ag{|F_*-NmX1i)8f;6O z=ivuLUFqM)knO5pWAlVkMa%z9Mdxv#v$zUd2Xl_rwSXO zH8o=)9zryT*5XkEViEL7paB<`=Vo-;@*o)~Q3DcOrRpfrYG|2Xk&ZPdsxsFTg3=FB zL6n!qnv;PKzB*iJUCkPJ^qGR;LKCV4I@UlE#Spao%b-Jf+~7=c-JJ`=QyMqswiFB-ge?W~VV-&VZr{rjleQTe?8(CS+|$%Y8}l9`I( zJ>Y-YXpCUw4_{`Uf!OWa=W(xQMnilp3k@0kP^)FpNS))Y>u538#)e_~j zZLCTb%s`7rvLY;-jzm7KrR$&&bVq}8_e)AP5v?zVQl?INnOm=}v<=O)|9jmfSo?5$ zXL!-3R@0?VeGy?{VI*h^i<^0779w!noUavzUQtiB*KgfwUaU6j_0K@BHg~{32 zB!EybcQKV|GuJfhk(=YbgPM?h%0^!2^wBbGj|45EJGK`7)>-AkxM3VkOJr73A&H0X z%kAy0h#ibPx9~L!A++~#K%>HCh}UzcmS5_balQqm>@^75sAs`nreS2&PBp{vXAxMf z2rlWmlf)Mp3@rWEvq~gSmrdGmTF2n+AyWWcyX;8M9o`B)9P-pgvFVJ!5`~B5KHD1} z&4%NeTBzV6u=riF$#!HYu;dn1?{Qnvg}~aM;kx9SlmqXXrYtd~jWUIWYxCZ5JftJH zD%ET`>utS>%Fbf9a7gp0rRX zqBMq_6hbQ6%NdAG{9{IAXJF@!1QBJkKDQ8^tVLED*0{Pr9tfmq6Q47Mu-?aWSHkpf z1vVhJnk9uFwZM-LvUjk{Vj1F5>gA*IG*v3I19(%^GI50a4PsAib(~RbM$%jIvwAg? zF?bYvckIu1O<>;_oAtgpEOhg(Lh_DQ?LATKft=3T-FbDVng5)wvuS?+T1v+&3&OfG z{AQ*xzG!Sug1c$@>jgy%40(vw|EI|R|#K*QNt?JGz%aM7Ul*5jd(us`q&1VLMuM%fQc*vCH(A!6M znxQ-~M*G=hpyFVhvK;V^8(Z{(WDfRDWI)v`9(Ak1Wf4_8Btlf%gET{N9O@15)_@sh z8)y)01Jt;25NI6~gFr%s00hV(d=Mzlk%EBdiR0TZ7!GXf@#C7H>I{Gi1Sm$|1Qda3 zV5nYt!DvtC7pnsdw2z+*))KWk!sqQ-?T4+CBm5r<g1G>O*Z2$lO literal 0 HcmV?d00001 diff --git a/Tank/Tank/Resources/up.png b/Tank/Tank/Resources/up.png new file mode 100644 index 0000000000000000000000000000000000000000..b1f434570dd6cdb667762c0d76887c0e1bb0ea73 GIT binary patch literal 1437 zcmcgs`%{t$6#YJe0_h=$u4#xVidl&@`AB936j!uDP}H(C$!4?7)KWupR6bu|PGLC~ zlBS_0T0XL=HK~-f%yKJD+n$tIno%lkLS&@-HM9FK?99FA&bepK{pHS_5-ulriG`g7 z002uu*sO4PiheYDA&fo#f_`{_Y2m>EK+A&_?_q-6!`#9IfJ;)WS%88$CY8M{4FHz* z{Aln_igGsqpw@@5nEcGR$?7eMJ0b~p%55o5LG7Nm$sV_gI?C4I=}oH?gj+>1YH7tp zZ+>S~XJcq|?9==ag=BRGg}wJe8Nr=k@8ef)iDp~l)XQ<|@Fw5N^wIg7*{yDNRX$my zcP~HBtF_nD#GA**=1TB`7i7e4GwI%)Yhg4o->CFloym(rBr@@+$B9i zh6mKI3lAX-yRPcPym={#V}XUuNwm@NqMgwv*pbuhB=N@-8^L?MIf9wR9Na?_ z&nE=U6_}3iCUdEbCEDNt9}|ib zX@BDE#S=V$9_rC>vKt>L-sxAgi7NvZcdfUmsI`O-j1gSbEvR_Y6`lmC!UI~>NHtLJ zP=yR*=7*VOHD^%_(^P){^w*N%K9ZYo+Y72$COr%PeM+A7j`!vnqVe=j?iVIPc=XMV zw>E(Gb+OS!H=YEswfly@myNWO7CAr3K;Ukw;uR{RN6)D{)yjxIw!oiN>S!;uRlT^-d z$SZ(RA=Bc3kw1``YgWnuuMTaKjxEsq9C|e@&`?{p2pjm&3P3`OHJbUlQPB|nNc3|=lRT2BC zJhY`S$FejL^!E0C2@apA;kOfv%r%deAvD1gDnSI%E>4vRMny-{18MIlkyY5%*bSqo z)RF2LyXPls_-)p4moxcjk?_&1(P-=!5Tx17Q(j`;hHF!{;go7lgBOiPE4iPO8|3Oc zou_)1enable + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file -- 2.25.1 From d50ab780376b4c4d837186fb4d12ad7ace453310 Mon Sep 17 00:00:00 2001 From: elizaveta Date: Tue, 26 Mar 2024 23:51:09 +0400 Subject: [PATCH 4/6] commit --- Tank/Tank/DrawningTank.cs | 44 +++-- Tank/Tank/EntityTank.cs | 1 + Tank/Tank/FormTank.cs | 3 +- labalaba2/lab2/SourceZhadny.cpp | 135 +++++++++++++++ labalaba2/lab2/lab2.vcxproj | 135 +++++++++++++++ labalaba2/lab2/lab2.vcxproj.filters | 22 +++ labalaba2/lab2z3/Zadanie3.cpp | 63 +++++++ labalaba2/lab2z3/lab2z3.vcxproj | 135 +++++++++++++++ labalaba2/lab2z3/lab2z3.vcxproj.filters | 22 +++ labalaba2/labalaba2.sln | 51 ++++++ labalaba2/labalaba2/SourceDinam.cpp | 154 ++++++++++++++++++ labalaba2/labalaba2/labalaba2.vcxproj | 135 +++++++++++++++ labalaba2/labalaba2/labalaba2.vcxproj.filters | 22 +++ 13 files changed, 907 insertions(+), 15 deletions(-) create mode 100644 labalaba2/lab2/SourceZhadny.cpp create mode 100644 labalaba2/lab2/lab2.vcxproj create mode 100644 labalaba2/lab2/lab2.vcxproj.filters create mode 100644 labalaba2/lab2z3/Zadanie3.cpp create mode 100644 labalaba2/lab2z3/lab2z3.vcxproj create mode 100644 labalaba2/lab2z3/lab2z3.vcxproj.filters create mode 100644 labalaba2/labalaba2.sln create mode 100644 labalaba2/labalaba2/SourceDinam.cpp create mode 100644 labalaba2/labalaba2/labalaba2.vcxproj create mode 100644 labalaba2/labalaba2/labalaba2.vcxproj.filters diff --git a/Tank/Tank/DrawningTank.cs b/Tank/Tank/DrawningTank.cs index 70c7430..094d06e 100644 --- a/Tank/Tank/DrawningTank.cs +++ b/Tank/Tank/DrawningTank.cs @@ -31,7 +31,7 @@ public class DrawningTank /// /// Ширина прорисовки автомобиля /// - private readonly int _drawningTankWidth = 145; + private readonly int _drawningTankWidth = 218; /// /// Высота прорисовки автомобиля /// @@ -49,7 +49,7 @@ public class DrawningTank public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool pushka, bool pulemet) { EntityTank = new EntityTank(); - EntityTank.Init(speed, weight, bodyColor, additionalColor,pushka, pulemet); + EntityTank.Init(speed, weight, bodyColor, additionalColor, pushka, pulemet); _pictureWidth = null; _pictureHeight = null; _startPosX = null; @@ -161,14 +161,32 @@ public class DrawningTank Brush additionalBrush = new SolidBrush(EntityTank.AdditionalColor); Brush bodyBrush = new SolidBrush(EntityTank.BodyColor); + //linii v gusenice + Point p4 = new Point(_startPosX.Value + 100, _startPosY.Value + 10); + Point p5 = new Point(_startPosX.Value + 100, _startPosY.Value + 10); + Point p6 = new Point(_startPosX.Value + 100, _startPosY.Value + 10); + Point p7 = new Point(_startPosX.Value + 100, _startPosY.Value + 10); + Point[] p_pulemet = { p4, p5, p6, p7 }; + g.FillPolygon(additionalBrush, p_pulemet); + g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 45, 150, 60); g.DrawEllipse(pen, _startPosX.Value + 5, _startPosY.Value + 60, 33, 33); g.DrawEllipse(pen, _startPosX.Value + 110, _startPosY.Value + 60, 33, 33); + + //otrisovka gusenici + g.DrawEllipse(pen, _startPosX.Value + 11, _startPosY.Value + 66, 20, 20); + g.DrawEllipse(pen, _startPosX.Value + 117, _startPosY.Value + 66, 20, 20); + g.DrawEllipse(pen, _startPosX.Value + 35, _startPosY.Value + 80, 16, 16); g.DrawEllipse(pen, _startPosX.Value + 55, _startPosY.Value + 83, 16, 16); g.DrawEllipse(pen, _startPosX.Value + 75, _startPosY.Value + 83, 16, 16); g.DrawEllipse(pen, _startPosX.Value + 95, _startPosY.Value + 80, 16, 16); + g.FillEllipse(bodyBrush, _startPosX.Value + 38, _startPosY.Value + 83, 10, 10); + g.FillEllipse(bodyBrush, _startPosX.Value + 58, _startPosY.Value + 86, 10, 10); + g.FillEllipse(bodyBrush, _startPosX.Value + 78, _startPosY.Value + 86, 10, 10); + g.FillEllipse(bodyBrush, _startPosX.Value + 98, _startPosY.Value + 83, 10, 10); + g.FillEllipse(bodyBrush, _startPosX.Value + 45, _startPosY.Value + 55, 15, 15); g.FillEllipse(bodyBrush, _startPosX.Value + 65, _startPosY.Value + 55, 15, 15); g.FillEllipse(bodyBrush, _startPosX.Value + 85, _startPosY.Value + 55, 15, 15); @@ -176,17 +194,17 @@ public class DrawningTank g.FillRectangle(bodyBrush, _startPosX.Value + 30, _startPosY.Value + 10, 100, 30); g.FillRectangle(bodyBrush, _startPosX.Value + 5, _startPosY.Value + 40, 140, 25); - if(EntityTank.Pushka) - g.FillRectangle(additionalBrush, _startPosX.Value + 120, _startPosY.Value + 20, 100, 15); + //if(EntityTank.Pushka) + // g.FillRectangle(additionalBrush, _startPosX.Value + 120, _startPosY.Value + 20, 100, 15); - if (EntityTank.Pulemet) - { - Point p = new Point(_startPosX.Value + 75, _startPosY.Value + 10); - Point p1 = new Point(_startPosX.Value + 80, _startPosY.Value + 1); - Point p2 = new Point(_startPosX.Value + 87, _startPosY.Value + 2); - Point p3 = new Point(_startPosX.Value + 80, _startPosY.Value + 10); - Point[] p_pulemet = { p, p1, p2, p3 }; - g.FillPolygon(additionalBrush, p_pulemet); - } + //if (EntityTank.Pulemet) + //{ + // Point p = new Point(_startPosX.Value + 75, _startPosY.Value + 10); + // Point p1 = new Point(_startPosX.Value + 80, _startPosY.Value + 1); + // Point p2 = new Point(_startPosX.Value + 87, _startPosY.Value + 2); + // Point p3 = new Point(_startPosX.Value + 80, _startPosY.Value + 10); + // Point[] p_pulemet = { p, p1, p2, p3 }; + // g.FillPolygon(additionalBrush, p_pulemet); + //} } } diff --git a/Tank/Tank/EntityTank.cs b/Tank/Tank/EntityTank.cs index 39a4618..b8303da 100644 --- a/Tank/Tank/EntityTank.cs +++ b/Tank/Tank/EntityTank.cs @@ -26,6 +26,7 @@ public class EntityTank /// Признак (опция) наличия антикрыла /// public bool Pulemet { get; private set; } + public bool Gusenica { get; private set; } /// /// Шаг перемещения автомобиля /// diff --git a/Tank/Tank/FormTank.cs b/Tank/Tank/FormTank.cs index f92df8d..f2ab440 100644 --- a/Tank/Tank/FormTank.cs +++ b/Tank/Tank/FormTank.cs @@ -48,8 +48,7 @@ namespace Tank Random random = new(); _drawningTank = new DrawningTank(); - _drawningTank.Init(random.Next(100, 300), random.Next(1000, - 3000), + _drawningTank.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), diff --git a/labalaba2/lab2/SourceZhadny.cpp b/labalaba2/lab2/SourceZhadny.cpp new file mode 100644 index 0000000..cf22f5b --- /dev/null +++ b/labalaba2/lab2/SourceZhadny.cpp @@ -0,0 +1,135 @@ +#include +#include +#include +class Item { +private: + std::string name; + int weight; + int price; +public: + + int GetItemWeight() { + return weight; + } + int GetItemPrice() { + return price; + } + double GetPriceOfWeight() { + return price / (double)weight; + } + void PrintParametres() { + std::cout << "\tName item: " << name << "\n\t\tWeight: " << weight << "\n\t\tPrice:" << price << std::endl; + } + void SetParametresOfItem() { + std::cout << "Enter name of item: "; + std::cin >> name; + std::cout << std::endl; + std::cout << "Enter weight of item: "; + std::cin >> weight; + std::cout << std::endl; + std::cout << "Enter price of item: "; + std::cin >> price; + std::cout << std::endl; + } +}; + +class ItemsHeap { +private: + bool sorted = false; + std::vector itemsHeap; + void m_swap(int i_1, int i_2) { + Item tmp = itemsHeap[i_1]; + itemsHeap[i_1] = itemsHeap[i_2]; + itemsHeap[i_2] = tmp; + } + void sort_items() { + int i_mx = 0; + for (int i = 0; i < itemsHeap.size(); ++i) { + i_mx = i; + for (int j = i + 1; j < itemsHeap.size(); ++j) { + if (itemsHeap[j].GetPriceOfWeight() > itemsHeap[i_mx].GetPriceOfWeight()) { + i_mx = j; + } + } + if (i != i_mx) + m_swap(i, i_mx); + } + } +public: + int GetSizeHeap() { + return itemsHeap.size(); + } + void AddItemInHeap() { + Item newItem; + newItem.SetParametresOfItem(); + itemsHeap.push_back(newItem); + } + Item getItem() { + if (!sorted) { + sort_items(); + sorted = true; + } + Item temp = itemsHeap[0]; + itemsHeap.erase(itemsHeap.begin()); + return temp; + } +}; + +class Knapsack { +private: + int max_weight; + int weight = 0; + int price = 0; + ItemsHeap heap; + std::vector items; + void SumOfItems(Item temp) { + price += temp.GetItemPrice(); + } + void WeightOfItems(Item temp) { + weight += temp.GetItemWeight(); + } +public: + int GetSizeOfHeapOnFloor() { + return heap.GetSizeHeap(); + } + void SetMaxWeight() { + std::cout << "Enter max weight: "; + std::cin >> max_weight; + std::cout << std::endl; + } + void PrintItems() { + std::cout << "Items:\n"; + for (int i = 0; i < items.size(); ++i) { + items[i].PrintParametres(); + } + } + void PrintParametresKnapsack() { + std::cout << "Backpack parametres:\n" << "\tPrice: " << price << " " << "\n\tWeight: " << weight << " " << "\n\tMax weight: " << max_weight << std::endl; + PrintItems(); + } + void AddItemOnFloor() { + heap.AddItemInHeap(); + } + void AddItemInKnapsack() { + while (heap.GetSizeHeap() > 0) { + Item temp = heap.getItem(); + if (temp.GetItemWeight() + weight <= max_weight) + { + items.push_back(temp); + SumOfItems(temp); + WeightOfItems(temp); + } + else + break; + } + std::cout << "Complete task" << std::endl; + } +}; + +void main() { + Knapsack backpack; + backpack.SetMaxWeight(); + backpack.AddItemOnFloor(); + backpack.AddItemInKnapsack(); + backpack.PrintParametresKnapsack(); +} \ No newline at end of file diff --git a/labalaba2/lab2/lab2.vcxproj b/labalaba2/lab2/lab2.vcxproj new file mode 100644 index 0000000..d5d79ac --- /dev/null +++ b/labalaba2/lab2/lab2.vcxproj @@ -0,0 +1,135 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {94371f76-b2cc-4212-8f44-31c220e94e22} + lab2 + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/labalaba2/lab2/lab2.vcxproj.filters b/labalaba2/lab2/lab2.vcxproj.filters new file mode 100644 index 0000000..01dcf8d --- /dev/null +++ b/labalaba2/lab2/lab2.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Исходные файлы + + + \ No newline at end of file diff --git a/labalaba2/lab2z3/Zadanie3.cpp b/labalaba2/lab2z3/Zadanie3.cpp new file mode 100644 index 0000000..de4a8d8 --- /dev/null +++ b/labalaba2/lab2z3/Zadanie3.cpp @@ -0,0 +1,63 @@ +#include + + +void m_swap(int* arr, int i_1, int i_2) { + int tmp = arr[i_1]; + arr[i_1] = arr[i_2]; + arr[i_2] = tmp; +} +int fib(int n) { //O(2**n) + if (n < 2) + return 1; + return fib(n - 1) + fib(n - 2); +} + +void sort_choice(int arr[], int size) { //n*n + int i_mn = 0; + for (int i = 0; i < size; ++i) { + i_mn = i; + for (int j = i + 1; j < size; ++j) { + if (arr[j] < arr[i_mn]) { + i_mn = j; + } + } + if (i != i_mn) + m_swap(arr, i, i_mn); + } +} + + +void quickSort(int* arr, int left, int right) //n logN +{ + int piv; + int index; + int _left = left; + int _right = right; + piv = arr[left]; + while (left < right) + { + while ((arr[right] > piv) && (left < right)) + right--; + if (left != right) + { + arr[left] = arr[right]; + left++; + } + while ((arr[left] < piv) && (left < right)) + left++; + if (left != right) + { + arr[right] = arr[left]; + right--; + } + } + arr[left] = piv; + index = left; + left = _left; + right = _right; + if (left < index) + quickSort(arr, left, index - 1); + if (right > index) + quickSort(arr, index + 1, right); +} + diff --git a/labalaba2/lab2z3/lab2z3.vcxproj b/labalaba2/lab2z3/lab2z3.vcxproj new file mode 100644 index 0000000..d6b7dd8 --- /dev/null +++ b/labalaba2/lab2z3/lab2z3.vcxproj @@ -0,0 +1,135 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {5e968207-3ace-4f80-968b-65cd0841b6de} + lab2z3 + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/labalaba2/lab2z3/lab2z3.vcxproj.filters b/labalaba2/lab2z3/lab2z3.vcxproj.filters new file mode 100644 index 0000000..b691508 --- /dev/null +++ b/labalaba2/lab2z3/lab2z3.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Исходные файлы + + + \ No newline at end of file diff --git a/labalaba2/labalaba2.sln b/labalaba2/labalaba2.sln new file mode 100644 index 0000000..726c7c0 --- /dev/null +++ b/labalaba2/labalaba2.sln @@ -0,0 +1,51 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.34221.43 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "labalaba2", "labalaba2\labalaba2.vcxproj", "{78A2C6D7-BAB1-4CE3-B6B6-B52B3BDCBE5E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lab2", "lab2\lab2.vcxproj", "{94371F76-B2CC-4212-8F44-31C220E94E22}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lab2z3", "lab2z3\lab2z3.vcxproj", "{5E968207-3ACE-4F80-968B-65CD0841B6DE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {78A2C6D7-BAB1-4CE3-B6B6-B52B3BDCBE5E}.Debug|x64.ActiveCfg = Debug|x64 + {78A2C6D7-BAB1-4CE3-B6B6-B52B3BDCBE5E}.Debug|x64.Build.0 = Debug|x64 + {78A2C6D7-BAB1-4CE3-B6B6-B52B3BDCBE5E}.Debug|x86.ActiveCfg = Debug|Win32 + {78A2C6D7-BAB1-4CE3-B6B6-B52B3BDCBE5E}.Debug|x86.Build.0 = Debug|Win32 + {78A2C6D7-BAB1-4CE3-B6B6-B52B3BDCBE5E}.Release|x64.ActiveCfg = Release|x64 + {78A2C6D7-BAB1-4CE3-B6B6-B52B3BDCBE5E}.Release|x64.Build.0 = Release|x64 + {78A2C6D7-BAB1-4CE3-B6B6-B52B3BDCBE5E}.Release|x86.ActiveCfg = Release|Win32 + {78A2C6D7-BAB1-4CE3-B6B6-B52B3BDCBE5E}.Release|x86.Build.0 = Release|Win32 + {94371F76-B2CC-4212-8F44-31C220E94E22}.Debug|x64.ActiveCfg = Debug|x64 + {94371F76-B2CC-4212-8F44-31C220E94E22}.Debug|x64.Build.0 = Debug|x64 + {94371F76-B2CC-4212-8F44-31C220E94E22}.Debug|x86.ActiveCfg = Debug|Win32 + {94371F76-B2CC-4212-8F44-31C220E94E22}.Debug|x86.Build.0 = Debug|Win32 + {94371F76-B2CC-4212-8F44-31C220E94E22}.Release|x64.ActiveCfg = Release|x64 + {94371F76-B2CC-4212-8F44-31C220E94E22}.Release|x64.Build.0 = Release|x64 + {94371F76-B2CC-4212-8F44-31C220E94E22}.Release|x86.ActiveCfg = Release|Win32 + {94371F76-B2CC-4212-8F44-31C220E94E22}.Release|x86.Build.0 = Release|Win32 + {5E968207-3ACE-4F80-968B-65CD0841B6DE}.Debug|x64.ActiveCfg = Debug|x64 + {5E968207-3ACE-4F80-968B-65CD0841B6DE}.Debug|x64.Build.0 = Debug|x64 + {5E968207-3ACE-4F80-968B-65CD0841B6DE}.Debug|x86.ActiveCfg = Debug|Win32 + {5E968207-3ACE-4F80-968B-65CD0841B6DE}.Debug|x86.Build.0 = Debug|Win32 + {5E968207-3ACE-4F80-968B-65CD0841B6DE}.Release|x64.ActiveCfg = Release|x64 + {5E968207-3ACE-4F80-968B-65CD0841B6DE}.Release|x64.Build.0 = Release|x64 + {5E968207-3ACE-4F80-968B-65CD0841B6DE}.Release|x86.ActiveCfg = Release|Win32 + {5E968207-3ACE-4F80-968B-65CD0841B6DE}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2B4A490B-BC2E-4EA7-B0EA-55C5328D08A6} + EndGlobalSection +EndGlobal diff --git a/labalaba2/labalaba2/SourceDinam.cpp b/labalaba2/labalaba2/SourceDinam.cpp new file mode 100644 index 0000000..4dd21dd --- /dev/null +++ b/labalaba2/labalaba2/SourceDinam.cpp @@ -0,0 +1,154 @@ +#include +#include +#include + + +class Item { +private: + std::string name; + int weight; + int price; +public: + int GetItemWeight() { + return weight; + } + int GetItemPrice() { + return price; + } + double GetPriceOfWeight() { + return price / (double)weight; + } + void PrintParametres() { + std::cout << "\tName item: " << name << "\n\tWeight: " << weight << "\n\tPrice:" << price << std::endl; + } + void SetParametresOfItem() { + std::cout << "Enter name of item: "; + std::cin >> name; + std::cout << std::endl; + std::cout << "Enter weight of item: "; + std::cin >> weight; + std::cout << std::endl; + std::cout << "Enter price of item: "; + std::cin >> price; + std::cout << std::endl; + } +}; + +class ItemsHeap { +private: + std::vector itemsHeap; +public: + int GetSizeHeap() { + return itemsHeap.size(); + } + void AddItemInHeap() { + Item newItem; + newItem.SetParametresOfItem(); + itemsHeap.push_back(newItem); + } + Item getItem(int i) { + return itemsHeap[i]; + } +}; +class Knapsack { +private: + int max_weight; + int weight = 0; + int price = 0; + ItemsHeap heap; + std::vector items; + + void SumOfItems(Item temp) { + price += temp.GetItemPrice(); + } + void WeightOfItems(Item temp) { + weight += temp.GetItemWeight(); + } + void PushItem(Item temp) { + items.push_back(temp); + SumOfItems(temp); + WeightOfItems(temp); + } + void PrintItems() { + std::cout << "Items:\n"; + for (int i = 0; i < items.size(); ++i) { + items[i].PrintParametres(); + } + } +public: + int GetPiceOfKnapsack() { + return price; + } + int GetSizeOfHeapOnFloor() { + return heap.GetSizeHeap(); + } + void SetMaxWeight() { + std::cout << "Enter max weight: "; + std::cin >> max_weight; + std::cout << std::endl; + } + void PrintParametresKnapsack() { + std::cout << "Backpack parametres:\n" << "\tPrice: " << price << " " << "\n\tWeight: " << weight << " " << "\n\tMax weight: " << max_weight << std::endl; + PrintItems(); + } + void AddItemOnFloor() { + heap.AddItemInHeap(); + } + void AddItemInKnapsack() { + if (heap.GetSizeHeap() > 1) { + Knapsack** kp = new Knapsack * [heap.GetSizeHeap() + 1]; + Knapsack temp, temp2; + int max_price = 0, i_mx = 0, j_mx = 0; + for (int i = 0; i < max_weight; ++i) { + kp[i] = new Knapsack[max_weight + 1]; + } + for (int i = 0; i < heap.GetSizeHeap() + 1; ++i) { + for (int j = 0; j < max_weight + 1; ++j) { + if (i == 0 || j == 0) + { + kp[i][j] = temp; + } + else if (i == 1) { + if (heap.getItem(0).GetItemWeight() <= j) + kp[1][j].PushItem(heap.getItem(0)); + else + kp[1][j] = temp; + } + else + { + if (heap.getItem(i - 1).GetItemWeight() > j) + kp[i][j] = kp[i - 1][j]; + else + { + int newPrice = heap.getItem(i - 1).GetItemPrice() + kp[i - 1][j - heap.getItem(i - 1).GetItemWeight()].GetPiceOfKnapsack(); + if (kp[i - 1][j].GetPiceOfKnapsack() > newPrice) + kp[i][j] = kp[i - 1][j]; + else + { + kp[i][j] = kp[i - 1][j - heap.getItem(i - 1).GetItemWeight()]; + kp[i][j].PushItem(heap.getItem(i - 1)); + temp2 = kp[i][j]; + } + } + } + } + } + for (int i = 0; i < temp2.items.size(); ++i) { + PushItem(temp2.items[i]); + } + std::cout << "Complete task" << std::endl; + } + else { + PushItem(heap.getItem(0)); + } + } +}; + +void main() { + Knapsack backpack; + backpack.SetMaxWeight(); + backpack.AddItemOnFloor(); + backpack.AddItemOnFloor(); + backpack.AddItemInKnapsack(); + backpack.PrintParametresKnapsack(); +} \ No newline at end of file diff --git a/labalaba2/labalaba2/labalaba2.vcxproj b/labalaba2/labalaba2/labalaba2.vcxproj new file mode 100644 index 0000000..59521ad --- /dev/null +++ b/labalaba2/labalaba2/labalaba2.vcxproj @@ -0,0 +1,135 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {78a2c6d7-bab1-4ce3-b6b6-b52b3bdcbe5e} + labalaba2 + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/labalaba2/labalaba2/labalaba2.vcxproj.filters b/labalaba2/labalaba2/labalaba2.vcxproj.filters new file mode 100644 index 0000000..bd31792 --- /dev/null +++ b/labalaba2/labalaba2/labalaba2.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Исходные файлы + + + \ No newline at end of file -- 2.25.1 From 337151391d55e143c4d260f120e86c54230622e0 Mon Sep 17 00:00:00 2001 From: elizaveta Date: Tue, 26 Mar 2024 23:59:57 +0400 Subject: [PATCH 5/6] commit --- Tank/Tank/DrawningTank.cs | 39 +++++++++++---------------------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/Tank/Tank/DrawningTank.cs b/Tank/Tank/DrawningTank.cs index 094d06e..48820a5 100644 --- a/Tank/Tank/DrawningTank.cs +++ b/Tank/Tank/DrawningTank.cs @@ -161,32 +161,15 @@ public class DrawningTank Brush additionalBrush = new SolidBrush(EntityTank.AdditionalColor); Brush bodyBrush = new SolidBrush(EntityTank.BodyColor); - //linii v gusenice - Point p4 = new Point(_startPosX.Value + 100, _startPosY.Value + 10); - Point p5 = new Point(_startPosX.Value + 100, _startPosY.Value + 10); - Point p6 = new Point(_startPosX.Value + 100, _startPosY.Value + 10); - Point p7 = new Point(_startPosX.Value + 100, _startPosY.Value + 10); - Point[] p_pulemet = { p4, p5, p6, p7 }; - g.FillPolygon(additionalBrush, p_pulemet); - g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 45, 150, 60); g.DrawEllipse(pen, _startPosX.Value + 5, _startPosY.Value + 60, 33, 33); g.DrawEllipse(pen, _startPosX.Value + 110, _startPosY.Value + 60, 33, 33); - //otrisovka gusenici - g.DrawEllipse(pen, _startPosX.Value + 11, _startPosY.Value + 66, 20, 20); - g.DrawEllipse(pen, _startPosX.Value + 117, _startPosY.Value + 66, 20, 20); - g.DrawEllipse(pen, _startPosX.Value + 35, _startPosY.Value + 80, 16, 16); g.DrawEllipse(pen, _startPosX.Value + 55, _startPosY.Value + 83, 16, 16); g.DrawEllipse(pen, _startPosX.Value + 75, _startPosY.Value + 83, 16, 16); g.DrawEllipse(pen, _startPosX.Value + 95, _startPosY.Value + 80, 16, 16); - g.FillEllipse(bodyBrush, _startPosX.Value + 38, _startPosY.Value + 83, 10, 10); - g.FillEllipse(bodyBrush, _startPosX.Value + 58, _startPosY.Value + 86, 10, 10); - g.FillEllipse(bodyBrush, _startPosX.Value + 78, _startPosY.Value + 86, 10, 10); - g.FillEllipse(bodyBrush, _startPosX.Value + 98, _startPosY.Value + 83, 10, 10); - g.FillEllipse(bodyBrush, _startPosX.Value + 45, _startPosY.Value + 55, 15, 15); g.FillEllipse(bodyBrush, _startPosX.Value + 65, _startPosY.Value + 55, 15, 15); g.FillEllipse(bodyBrush, _startPosX.Value + 85, _startPosY.Value + 55, 15, 15); @@ -194,17 +177,17 @@ public class DrawningTank g.FillRectangle(bodyBrush, _startPosX.Value + 30, _startPosY.Value + 10, 100, 30); g.FillRectangle(bodyBrush, _startPosX.Value + 5, _startPosY.Value + 40, 140, 25); - //if(EntityTank.Pushka) - // g.FillRectangle(additionalBrush, _startPosX.Value + 120, _startPosY.Value + 20, 100, 15); + if (EntityTank.Pushka) + g.FillRectangle(additionalBrush, _startPosX.Value + 120, _startPosY.Value + 20, 100, 15); - //if (EntityTank.Pulemet) - //{ - // Point p = new Point(_startPosX.Value + 75, _startPosY.Value + 10); - // Point p1 = new Point(_startPosX.Value + 80, _startPosY.Value + 1); - // Point p2 = new Point(_startPosX.Value + 87, _startPosY.Value + 2); - // Point p3 = new Point(_startPosX.Value + 80, _startPosY.Value + 10); - // Point[] p_pulemet = { p, p1, p2, p3 }; - // g.FillPolygon(additionalBrush, p_pulemet); - //} + if (EntityTank.Pulemet) + { + Point p = new Point(_startPosX.Value + 75, _startPosY.Value + 10); + Point p1 = new Point(_startPosX.Value + 80, _startPosY.Value + 1); + Point p2 = new Point(_startPosX.Value + 87, _startPosY.Value + 2); + Point p3 = new Point(_startPosX.Value + 80, _startPosY.Value + 10); + Point[] p_pulemet = { p, p1, p2, p3 }; + g.FillPolygon(additionalBrush, p_pulemet); + } } } -- 2.25.1 From 47eebb202f640a5957042abdd248ae2ab8f19271 Mon Sep 17 00:00:00 2001 From: elizaveta Date: Wed, 27 Mar 2024 02:29:55 +0400 Subject: [PATCH 6/6] ok --- Tank/Tank/FormTank.cs | 176 +++++++++++++++++++++--------------------- 1 file changed, 88 insertions(+), 88 deletions(-) diff --git a/Tank/Tank/FormTank.cs b/Tank/Tank/FormTank.cs index f2ab440..46566fd 100644 --- a/Tank/Tank/FormTank.cs +++ b/Tank/Tank/FormTank.cs @@ -8,95 +8,95 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -namespace Tank -{ - public partial class FormTank : Form - { - /// - /// Поле-объект для прорисовки объекта - /// - private DrawningTank? _drawningTank; - /// - /// Конструктор формы - /// - public FormTank() - { - InitializeComponent(); - } - /// - /// Метод прорисовки машины - /// - private void Draw() - { - if (_drawningTank == null) - { - return; - } - Bitmap bmp = new(pictureBoxTank.Width, - pictureBoxTank.Height); - Graphics gr = Graphics.FromImage(bmp); - _drawningTank.DrawTransport(gr); - pictureBoxTank.Image = bmp; - } - /// - /// Обработка нажатия кнопки "Создать" - /// - /// - /// - private void ButtonCreateTank_Click(object sender, EventArgs e) - { - Random random = new(); - _drawningTank = new DrawningTank(); +namespace Tank; - _drawningTank.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)), - Convert.ToBoolean(random.Next(0, 2))); - _drawningTank.SetPictureSize(pictureBoxTank.Width, - pictureBoxTank.Height); - _drawningTank.SetPosition(random.Next(10, 100), random.Next(10, - 100)); +public partial class FormTank : Form +{ + /// + /// Поле-объект для прорисовки объекта + /// + private DrawningTank? _drawningTank; + /// + /// Конструктор формы + /// + public FormTank() + { + InitializeComponent(); + } + /// + /// Метод прорисовки машины + /// + private void Draw() + { + if (_drawningTank == null) + { + return; + } + Bitmap bmp = new(pictureBoxTank.Width, + pictureBoxTank.Height); + Graphics gr = Graphics.FromImage(bmp); + _drawningTank.DrawTransport(gr); + pictureBoxTank.Image = bmp; + } + /// + /// Обработка нажатия кнопки "Создать" + /// + /// + /// + private void ButtonCreateTank_Click(object sender, EventArgs e) + { + Random random = new(); + _drawningTank = new DrawningTank(); + + _drawningTank.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)), + Convert.ToBoolean(random.Next(0, 2))); + _drawningTank.SetPictureSize(pictureBoxTank.Width, + pictureBoxTank.Height); + _drawningTank.SetPosition(random.Next(10, 100), random.Next(10, + 100)); + Draw(); + } + + /// + /// Перемещение объекта по форме (нажатие кнопок навигации) + /// + /// + /// + private void ButtonMove_Click(object sender, EventArgs e) + { + if (_drawningTank == null) + { + return; + } + string name = ((Button)sender)?.Name ?? string.Empty; + bool result = false; + switch (name) + { + case "buttonUp": + result = + _drawningTank.MoveTransport(DirectionType.Up); + break; + case "buttonDown": + result = + _drawningTank.MoveTransport(DirectionType.Down); + break; + case "buttonLeft": + result = + _drawningTank.MoveTransport(DirectionType.Left); + break; + case "buttonRight": + result = + _drawningTank.MoveTransport(DirectionType.Right); + break; + } + if (result) + { Draw(); } - /// - /// Перемещение объекта по форме (нажатие кнопок навигации) - /// - /// - /// - private void ButtonMove_Click(object sender, EventArgs e) - { - if (_drawningTank == null) - { - return; - } - string name = ((Button)sender)?.Name ?? string.Empty; - bool result = false; - switch (name) - { - case "buttonUp": - result = - _drawningTank.MoveTransport(DirectionType.Up); - break; - case "buttonDown": - result = - _drawningTank.MoveTransport(DirectionType.Down); - break; - case "buttonLeft": - result = - _drawningTank.MoveTransport(DirectionType.Left); - break; - case "buttonRight": - result = - _drawningTank.MoveTransport(DirectionType.Right); - break; - } - if (result) - { - Draw(); - } - } } -} +} \ No newline at end of file -- 2.25.1