From 0339e5feca46f0ff2d59120178e27f64566b2235 Mon Sep 17 00:00:00 2001 From: 1SooNoo1 Date: Sat, 16 Sep 2023 14:03:09 +0400 Subject: [PATCH] Lab_1_Kryukov_AI_Excavator --- .../lab_1_pojectExcavator/DrawingExcavator.cs | 19 ++++++++----- .../lab_1_pojectExcavator/EntityExcavator.cs | 1 + .../Excavator.Designer.cs | 28 ++++++++++++------- .../lab_1_pojectExcavator/Excavator.cs | 21 +++++++------- 4 files changed, 41 insertions(+), 28 deletions(-) diff --git a/lab_1_pojectExcavator/lab_1_pojectExcavator/DrawingExcavator.cs b/lab_1_pojectExcavator/lab_1_pojectExcavator/DrawingExcavator.cs index 631f5c8..5ce449c 100644 --- a/lab_1_pojectExcavator/lab_1_pojectExcavator/DrawingExcavator.cs +++ b/lab_1_pojectExcavator/lab_1_pojectExcavator/DrawingExcavator.cs @@ -92,7 +92,7 @@ namespace lab_1_pojectExcavator break; //вверх case DirectionType.Up: - if (_startPosY - EntityExcavator.Step > -60) + if (_startPosY - EntityExcavator.Step > -50) { _startPosY -= (int)EntityExcavator.Step; } @@ -106,7 +106,7 @@ namespace lab_1_pojectExcavator break; //вниз case DirectionType.Down: - if (_startPosY + EntityExcavator.Step < _pictureHeight- _excavatorHeight) + if (_startPosY + EntityExcavator.Step < _pictureHeight - _excavatorHeight) { _startPosY += (int)EntityExcavator.Step; } @@ -128,6 +128,7 @@ namespace lab_1_pojectExcavator Brush additionalBrush = new SolidBrush(EntityExcavator.AdditionalColor); if (EntityExcavator.BodyKit) { + g.FillRectangle(additionalBrush, _startPosX + 20, _startPosY + 120, 130, 10); g.DrawLine(pen, _startPosX + 20, _startPosY + 120, _startPosX + 150, _startPosY + 120); } //корпус @@ -149,19 +150,23 @@ namespace lab_1_pojectExcavator new Point(_startPosX + 150, _startPosY + 135), new Point(_startPosX + 145, _startPosY + 130)}; g.DrawPolygon(pen,points); + g.DrawEllipse(pen,_startPosX + 20,_startPosY + 130, 20,20); + g.DrawEllipse(pen, _startPosX + 40, _startPosY + 130, 20, 20); + g.DrawEllipse(pen, _startPosX + 60, _startPosY + 130, 20, 20); + g.DrawEllipse(pen, _startPosX + 80, _startPosY + 130, 20, 20); + g.DrawEllipse(pen, _startPosX + 100, _startPosY + 130, 20, 20); + g.DrawEllipse(pen, _startPosX + 120, _startPosY + 130, 20, 20); //ковш if (EntityExcavator.Backet) { Point[] pointsBacket = { - new Point(_startPosX+150, _startPosY+ 75), - new Point(_startPosX + 150, _startPosY+ 135), + new Point(_startPosX + 150, _startPosY + 75), + new Point(_startPosX + 150, _startPosY + 135), new Point(_startPosX + 195, _startPosY + 135), }; g.FillPolygon(additionalBrush, pointsBacket); + g.DrawPolygon(pen, pointsBacket); } - } - - } } diff --git a/lab_1_pojectExcavator/lab_1_pojectExcavator/EntityExcavator.cs b/lab_1_pojectExcavator/lab_1_pojectExcavator/EntityExcavator.cs index 3bfe4c1..26fa54c 100644 --- a/lab_1_pojectExcavator/lab_1_pojectExcavator/EntityExcavator.cs +++ b/lab_1_pojectExcavator/lab_1_pojectExcavator/EntityExcavator.cs @@ -54,6 +54,7 @@ namespace lab_1_pojectExcavator Weight = weight; BodyColor = bodyColor; AdditionalColor = additionalColor; + BodyKit = bodyKit; Backet = backet; } } diff --git a/lab_1_pojectExcavator/lab_1_pojectExcavator/Excavator.Designer.cs b/lab_1_pojectExcavator/lab_1_pojectExcavator/Excavator.Designer.cs index 1f9b0ad..7030905 100644 --- a/lab_1_pojectExcavator/lab_1_pojectExcavator/Excavator.Designer.cs +++ b/lab_1_pojectExcavator/lab_1_pojectExcavator/Excavator.Designer.cs @@ -41,8 +41,9 @@ // pictureBoxExcavator.Dock = DockStyle.Fill; pictureBoxExcavator.Location = new Point(0, 0); + pictureBoxExcavator.Margin = new Padding(3, 2, 3, 2); pictureBoxExcavator.Name = "pictureBoxExcavator"; - pictureBoxExcavator.Size = new Size(882, 453); + pictureBoxExcavator.Size = new Size(884, 461); pictureBoxExcavator.SizeMode = PictureBoxSizeMode.AutoSize; pictureBoxExcavator.TabIndex = 0; pictureBoxExcavator.TabStop = false; @@ -50,9 +51,10 @@ // buttonCreate // buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; - buttonCreate.Location = new Point(12, 412); + buttonCreate.Location = new Point(10, 430); + buttonCreate.Margin = new Padding(3, 2, 3, 2); buttonCreate.Name = "buttonCreate"; - buttonCreate.Size = new Size(94, 29); + buttonCreate.Size = new Size(82, 22); buttonCreate.TabIndex = 1; buttonCreate.Text = "Создать"; buttonCreate.UseVisualStyleBackColor = true; @@ -63,7 +65,8 @@ buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonDown.BackgroundImage = Properties.Resources.down_; buttonDown.BackgroundImageLayout = ImageLayout.Zoom; - buttonDown.Location = new Point(804, 412); + buttonDown.Location = new Point(816, 430); + buttonDown.Margin = new Padding(3, 2, 3, 2); buttonDown.Name = "buttonDown"; buttonDown.Size = new Size(30, 30); buttonDown.TabIndex = 2; @@ -75,7 +78,8 @@ buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonRight.BackgroundImage = Properties.Resources.right; buttonRight.BackgroundImageLayout = ImageLayout.Zoom; - buttonRight.Location = new Point(840, 412); + buttonRight.Location = new Point(847, 430); + buttonRight.Margin = new Padding(3, 2, 3, 2); buttonRight.Name = "buttonRight"; buttonRight.Size = new Size(30, 30); buttonRight.TabIndex = 3; @@ -84,9 +88,11 @@ // // buttonUp // + buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonUp.BackgroundImage = Properties.Resources.up; buttonUp.BackgroundImageLayout = ImageLayout.Zoom; - buttonUp.Location = new Point(804, 376); + buttonUp.Location = new Point(816, 396); + buttonUp.Margin = new Padding(3, 2, 3, 2); buttonUp.Name = "buttonUp"; buttonUp.Size = new Size(30, 30); buttonUp.TabIndex = 4; @@ -95,9 +101,11 @@ // // buttonLeft // + buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonLeft.BackgroundImage = Properties.Resources.left; buttonLeft.BackgroundImageLayout = ImageLayout.Zoom; - buttonLeft.Location = new Point(768, 412); + buttonLeft.Location = new Point(784, 430); + buttonLeft.Margin = new Padding(3, 2, 3, 2); buttonLeft.Name = "buttonLeft"; buttonLeft.Size = new Size(30, 30); buttonLeft.TabIndex = 5; @@ -106,18 +114,18 @@ // // Excavator // - AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(882, 453); + ClientSize = new Size(884, 461); Controls.Add(buttonLeft); Controls.Add(buttonUp); Controls.Add(buttonRight); Controls.Add(buttonDown); Controls.Add(buttonCreate); Controls.Add(pictureBoxExcavator); + Margin = new Padding(3, 2, 3, 2); Name = "Excavator"; Text = "Excavator"; - ((System.ComponentModel.ISupportInitialize)pictureBoxExcavator).EndInit(); ResumeLayout(false); PerformLayout(); diff --git a/lab_1_pojectExcavator/lab_1_pojectExcavator/Excavator.cs b/lab_1_pojectExcavator/lab_1_pojectExcavator/Excavator.cs index fd0bfaf..ba59694 100644 --- a/lab_1_pojectExcavator/lab_1_pojectExcavator/Excavator.cs +++ b/lab_1_pojectExcavator/lab_1_pojectExcavator/Excavator.cs @@ -33,7 +33,6 @@ namespace lab_1_pojectExcavator /// /// /// - /// /// /// @@ -44,15 +43,15 @@ namespace lab_1_pojectExcavator Random random = new(); _drawnigExcavator = new DrawingExcavator(); _drawnigExcavator.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)), pictureBoxExcavator.Width, pictureBoxExcavator.Height); - _drawnigExcavator.SetPosition(random.Next(10, 100), - random.Next(10, 100)); + 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)), + pictureBoxExcavator.Width, + pictureBoxExcavator.Height); + _drawnigExcavator.SetPosition(random.Next(10, 100), + random.Next(10, 100)); Draw(); } private void buttonMove_Click(object sender, EventArgs e) @@ -80,7 +79,7 @@ namespace lab_1_pojectExcavator Draw(); } - + } }