From fb90f09de89d8bbc269dc23759ca8c245d291495 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=20=D0=91=D0=BE=D0=BD=D0=B4=D0=B0?= =?UTF-8?q?=D1=80=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Tue, 20 Sep 2022 18:41:41 +0400 Subject: [PATCH 1/5] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=B0=E2=84=961.=20?= =?UTF-8?q?=D0=9D=D0=B5=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=B5=D0=BD?= =?UTF-8?q?=D0=BD=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Images/todown.png | Bin 0 -> 1298 bytes Images/toleft.png | Bin 0 -> 1298 bytes Images/toright.png | Bin 0 -> 1298 bytes Images/totop.png | Bin 0 -> 1298 bytes WarmlyShip/WarmlyShip/Direction.cs | 16 ++ WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs | 106 +++++++++++ WarmlyShip/WarmlyShip/EntityWarmlyShip.cs | 24 +++ WarmlyShip/WarmlyShip/Form1.Designer.cs | 39 ---- WarmlyShip/WarmlyShip/Form1.cs | 10 - WarmlyShip/WarmlyShip/FormClass.Designer.cs | 180 ++++++++++++++++++ WarmlyShip/WarmlyShip/FormClass.cs | 59 ++++++ WarmlyShip/WarmlyShip/FormClass.resx | 63 ++++++ WarmlyShip/WarmlyShip/Program.cs | 2 +- .../Properties/Resources.Designer.cs | 103 ++++++++++ .../{Form1.resx => Properties/Resources.resx} | 13 ++ WarmlyShip/WarmlyShip/Resources/todown.png | Bin 0 -> 1298 bytes WarmlyShip/WarmlyShip/Resources/toleft.png | Bin 0 -> 1298 bytes WarmlyShip/WarmlyShip/Resources/toright.png | Bin 0 -> 1298 bytes WarmlyShip/WarmlyShip/Resources/totop.png | Bin 0 -> 1298 bytes WarmlyShip/WarmlyShip/WarmlyShip.csproj | 15 ++ 20 files changed, 580 insertions(+), 50 deletions(-) create mode 100644 Images/todown.png create mode 100644 Images/toleft.png create mode 100644 Images/toright.png create mode 100644 Images/totop.png create mode 100644 WarmlyShip/WarmlyShip/Direction.cs create mode 100644 WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs create mode 100644 WarmlyShip/WarmlyShip/EntityWarmlyShip.cs delete mode 100644 WarmlyShip/WarmlyShip/Form1.Designer.cs delete mode 100644 WarmlyShip/WarmlyShip/Form1.cs create mode 100644 WarmlyShip/WarmlyShip/FormClass.Designer.cs create mode 100644 WarmlyShip/WarmlyShip/FormClass.cs create mode 100644 WarmlyShip/WarmlyShip/FormClass.resx create mode 100644 WarmlyShip/WarmlyShip/Properties/Resources.Designer.cs rename WarmlyShip/WarmlyShip/{Form1.resx => Properties/Resources.resx} (83%) create mode 100644 WarmlyShip/WarmlyShip/Resources/todown.png create mode 100644 WarmlyShip/WarmlyShip/Resources/toleft.png create mode 100644 WarmlyShip/WarmlyShip/Resources/toright.png create mode 100644 WarmlyShip/WarmlyShip/Resources/totop.png diff --git a/Images/todown.png b/Images/todown.png new file mode 100644 index 0000000000000000000000000000000000000000..074dc0003813b243413609b3c504b85e9b06db32 GIT binary patch literal 1298 zcmV+t1?~EYP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGf6951U69E94 zoEQKA1cFIKK~!i%&6-)LO;H%fFBvjMrjR#N=HY=nn2Nj^qYQaLLcB;QrR2#FiIg`F z9^}P?At^i=Lgw*GAu`KM8UDZRe5ZYmbI)0O?RC!C|N7Nk>+ZeR_pQB#Z+-hTYY3yB zVv-mu28h0*vuH2SXYpP<68FUgaYj5BbyHWdT3i-?Jh>v)h;G75K5wA6SSOZ>HdN$9 zZ=Msk!~^kKd=jXGz~TO4s2DGJj_JENAhwC8R8&K)#Cq{XSP#20u|WjyA&EE4(6l#9 zn{z}eEf>E954m6X}}ZhP%Rc(t3*FWOIVmsq6y6D!_$o zEJLWsi0FA+o!BQzs+X{fHc^o=S?99Z^`W9zI|UaIa8+ZSPb-GEZFYO8h>JJ{&-mvO zDl)2t0vp*-3j)AZf`1T@;b~UIs${VfQEXn91eHXCSr-8ywi1d*>LI9rkyO-B-31YD z5)s9ky(~Np^Ku2^_vTbMsEar)hDRkoVf<}D+k1s;IL>v?1othVVppzkgo1-G-Zr~8 z!pDiY@y0&k>IC5p_e87FiCkebg$jxrZzOf1l<|;c^CYC_o>LSWbA|a7Du@O!INmV0 zI#JH}X~I>r1^2OMj}xJcM-v41zN7FXR~SRVQ8>Y*j~fC_IT6x$G)i#) zPYON`AXg_s8;=ScNIHb#s^mm9j7J4SD9I!)rE*SirYNpYYdqp~#@XyC0 zp7+m+7#S@2*tnaDVlg2s3+)nG*IML*u#J%t|2R^hwStRSvqw;o5wY@+iNLn9M^Glo zRl$XPCh92aEwbXI_OXeNEETgRd|~`3xPcQ-J<}|7C<$h4VR$=-JJZE4!HtJSJ)FRJ zJNuGe=Sxu{@fDJr?M>8jIFS{%o(Dd*cnK%$O)w{FF|pYIEexmUy^S|9oNP|8I=0oG^NWNs83ubksT+&=gNaGSK4F_35IYe7 z62&G7#krO=Cb?J(je$*y?*Pt=hHEA)E_Q4jVQljG$Mja%PYpO|a4ulzAr=7A;q)p8 zC(g9-ScXk%zaX5c*$+Sn0EuEP6!(FwIH~>r0y9_nyn#~UP&84D6Kpp9L?^+IJP;G| zgCH2=?VJ~9#Y>Sw4Gn(*{zIKkvBup200000NkvXXu0mjf1A7mQ4J1C7DF6Tf07*qo IM6N<$f~rs;>i_@% literal 0 HcmV?d00001 diff --git a/Images/toleft.png b/Images/toleft.png new file mode 100644 index 0000000000000000000000000000000000000000..648ca1405e13202768dbf0c0ff27c10c58522cd9 GIT binary patch literal 1298 zcmV+t1?~EYP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGf6951U69E94 zoEQKA1c^yRK~!i%&6-Q7RaF?rZ=puMC`?78S*c{c2Z;k8MBvN{F({*nN747?>#TiFfA|gdx@WKb zt=G5K_pS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$JWN0xAkxr}+(UI>S3kqMwBZmYyGg56?DY*yJP zG3!*hPGDAvmqHIX$}?a*M5V(Za2ZS#JqCUOpMqt`5^6MV1A7mQ4J1C7DF6Tf07*qo IM6N<$g517qvH$=8 literal 0 HcmV?d00001 diff --git a/Images/totop.png b/Images/totop.png new file mode 100644 index 0000000000000000000000000000000000000000..02de3195ae52fc182b7a18d21c3993615d7e1dc7 GIT binary patch literal 1298 zcmV+t1?~EYP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGf6951U69E94 zoEQKA1b0b9K~!i%&6-KbjZqlKFPW#v6tXgA9u|fT64}WRW$4==AvOr5lx$2TDWxnd zEUZ|tkW339WS%}!#xiH74FBKjKG(h19nL-Px%a;R`o%f-eb0H${G8|gnxw+0yO=1( zi29AC6<00A67fh_`By|=5kxZti;#l9iH(9vLyPISNqiU7#q^sl zVu^YFOHkk)F;rArBLr)RI)94A!b=!WA#hBz6SWeH{dW-2~Yl7XWWQVR3Jor@%CLA5W`_Arc(EB>5@c?PQsFdB;C|ruhiU{4AhzO)M`A&c z0U>uDGv3M$)d;*;E3+FJ^U?`i<4`xWeB%x72yq*ME6&}6^5&2jD-f3vGUE#44~s%O z8JopP5vLKjIM|BD(*RrtbR+$59F;QO6rvH_`cPy$mlJw^Hi;N2Hf?ajZOF4>It>#( zvT6T-#M^X&d#bOB8GlQ#(1weUjhG^MpE6TF(uq+dJXFqjQ^-b)5xk3k6srNQ#+yPl zBBueqQ>aqoO~o2Po@*m=rjRY-StK0gYrLscBZwQ7Q)UsfjnV)_=)^@-P-v^<0yIgu zgbTSeO%`vW)IU8HE`cqxwUGu8t3(arPEpT)IFCBVx1&l5E&JSD`*_!eMA`3>?JB5>9QbWbCgQ9 zh{a+nQSppc2{IpxW@IE(L{0FTv6aw%MufhJMDW7`G7>5R%Gk*D7pE{sy9Gbq6(OR| zp~bdsXVy+K^3_||#h&i~NfS|VY~w=D##2zlgY2P!WF$oF`*!k|>|BQFy5K=BIBi6| zMO2(S1vc@KrR?;k=PkHBv=!*SlGm-a1N=Hy1k7zF`aBpusg8}RO6gr16eQZ zK&4K;6a^7IZ@Uw4*ew(x)&_H(fHF~WD<9X|!ac!64{=V|VF&n5IDmMul|=P;mZ?H4 zmVmOA#|Y!$I*+hVD3KF;jo`~+D>Bl0Ce8}h3ZI0y9Pn@Yp%EtM8yg1|L2&w%4Y-$iQeQ&Nt~6r+edT~_HCI3`A!f?;~IEgoDwnr zup^cF1J$OHze^KvlmGw#07*qoM6N<$f{YBKqI>TE0000 0) _startPosX -= warmlyShip.Step; + break; + case Direction.Up: //Вверх + if (_startPosY - warmlyShip.Step > 0) _startPosY -= warmlyShip.Step; + break; + case Direction.Right: //Вправо + if (_startPosX + _warmlyShipWidth + warmlyShip.Step < _pictureWidth) _startPosX += warmlyShip.Step; + break; + case Direction.Down: //Вниз + if (_startPosY + _warmlyShipHeight + warmlyShip.Step < _pictureHeight) _startPosY += warmlyShip.Step; + break; + } + } + + public void DrawTransport(Graphics g) + { + if (_startPosX < 0 || _startPosY < 0 || !_pictureHeight.HasValue || !_pictureWidth.HasValue) + { + return; + } + Pen pen = new(Color.Black, 2); + SolidBrush brush = new SolidBrush(warmlyShip?.BodyColor ?? Color.White); + g.FillPolygon(brush, new[] + { + new Point((int)(_startPosX), (int)(_startPosY + 20)), + new Point((int)(_startPosX + _warmlyShipWidth), (int)(_startPosY + 20)), + new Point((int)(_startPosX + _warmlyShipWidth - 25), (int)(_startPosY + _warmlyShipHeight)), + new Point((int)(_startPosX + 25), (int)(_startPosY + _warmlyShipHeight)) + }); + g.FillRectangle(brush, _startPosX + _warmlyShipWidth / 5, _startPosY, _warmlyShipWidth * 3 / 5, 20); + g.FillEllipse(new SolidBrush(Color.Aquamarine), _startPosX + _warmlyShipWidth / 5, _startPosY + 25, 20, 20); + g.FillEllipse(new SolidBrush(Color.Aquamarine), _startPosX + _warmlyShipWidth * 3 / 5 + 5, _startPosY + 25, 20, 20); + g.FillEllipse(new SolidBrush(Color.Aquamarine), _startPosX + _warmlyShipWidth * 2 / 5 + 2.5f, _startPosY + 25, 20, 20); + g.DrawPolygon(pen, new[] + { + new Point((int)(_startPosX), (int)(_startPosY + 20)), + new Point((int)(_startPosX + _warmlyShipWidth), (int)(_startPosY + 20)), + new Point((int)(_startPosX + _warmlyShipWidth - 25), (int)(_startPosY + _warmlyShipHeight)), + new Point((int)(_startPosX + 25), (int)(_startPosY + _warmlyShipHeight)) + }); + g.DrawRectangle(pen, _startPosX + _warmlyShipWidth / 5, _startPosY, _warmlyShipWidth * 3 / 5, 20); + g.DrawEllipse(new(Color.Blue, 2), _startPosX + _warmlyShipWidth / 5, _startPosY + 25, 20, 20); + g.DrawEllipse(new(Color.Blue, 2), _startPosX + _warmlyShipWidth * 3 / 5 + 5, _startPosY + 25, 20, 20); + g.DrawEllipse(new(Color.Blue, 2), _startPosX + _warmlyShipWidth * 2 / 5 + 2.5f, _startPosY + 25, 20, 20); + } + + public void ChangeBorders(int width, int height) + { + _pictureWidth = width; + _pictureHeight = height; + if (_pictureWidth <= _warmlyShipWidth || _pictureHeight <= _warmlyShipHeight) + { + _pictureWidth = null; + _pictureHeight = null; + return; + } + if (_startPosX + _warmlyShipWidth > _pictureWidth) + { + _startPosX = _pictureWidth.Value - _warmlyShipWidth; + } + if (_startPosY + _warmlyShipHeight > _pictureHeight) + { + _startPosY = _pictureHeight.Value - _warmlyShipHeight; + } + + } + } +} diff --git a/WarmlyShip/WarmlyShip/EntityWarmlyShip.cs b/WarmlyShip/WarmlyShip/EntityWarmlyShip.cs new file mode 100644 index 0000000..29576fb --- /dev/null +++ b/WarmlyShip/WarmlyShip/EntityWarmlyShip.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WarmlyShip +{ + internal class EntityWarmlyShip + { + public int Speed { get; private set; } //Скорость + public float Weight { get; private set; } //Вес + public Color BodyColor { get; private set; } //Цвет + public float Step => Speed * 100 / Weight; //Шаг при перемещении + + public void Init(int speed, float weight, Color bodyColor) + { + Random random = new Random(); + Speed = speed <= 0 ? random.Next(50, 150) : speed; + Weight = weight <= 0 ? random.Next(40, 70) : weight; + BodyColor = bodyColor; + } + } +} diff --git a/WarmlyShip/WarmlyShip/Form1.Designer.cs b/WarmlyShip/WarmlyShip/Form1.Designer.cs deleted file mode 100644 index 3873b6f..0000000 --- a/WarmlyShip/WarmlyShip/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace WarmlyShip -{ - 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/WarmlyShip/WarmlyShip/Form1.cs b/WarmlyShip/WarmlyShip/Form1.cs deleted file mode 100644 index bca3f86..0000000 --- a/WarmlyShip/WarmlyShip/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace WarmlyShip -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/WarmlyShip/WarmlyShip/FormClass.Designer.cs b/WarmlyShip/WarmlyShip/FormClass.Designer.cs new file mode 100644 index 0000000..26dca06 --- /dev/null +++ b/WarmlyShip/WarmlyShip/FormClass.Designer.cs @@ -0,0 +1,180 @@ +namespace WarmlyShip +{ + partial class FormClass + { + /// + /// 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.pictureBox = new System.Windows.Forms.PictureBox(); + this.statusStrip = new System.Windows.Forms.StatusStrip(); + this.toolStripStatusSpeed = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusWeight = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel(); + this.buttonRight = new System.Windows.Forms.Button(); + this.buttonUp = new System.Windows.Forms.Button(); + this.buttonLeft = new System.Windows.Forms.Button(); + this.buttonDown = new System.Windows.Forms.Button(); + this.ButtonCreate = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); + this.statusStrip.SuspendLayout(); + this.SuspendLayout(); + // + // pictureBox + // + this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.pictureBox.Location = new System.Drawing.Point(0, 0); + this.pictureBox.Name = "pictureBox"; + this.pictureBox.Size = new System.Drawing.Size(800, 428); + this.pictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; + this.pictureBox.TabIndex = 0; + this.pictureBox.TabStop = false; + this.pictureBox.Resize += new System.EventHandler(this.PictureBox_Resize); + // + // statusStrip + // + this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripStatusSpeed, + this.toolStripStatusWeight, + this.toolStripStatusLabelBodyColor}); + this.statusStrip.Location = new System.Drawing.Point(0, 428); + this.statusStrip.Name = "statusStrip"; + this.statusStrip.Size = new System.Drawing.Size(800, 22); + this.statusStrip.TabIndex = 1; + this.statusStrip.Text = "statusStrip1"; + // + // toolStripStatusSpeed + // + this.toolStripStatusSpeed.Name = "toolStripStatusSpeed"; + this.toolStripStatusSpeed.Size = new System.Drawing.Size(62, 17); + this.toolStripStatusSpeed.Text = "Скорость:"; + // + // toolStripStatusWeight + // + this.toolStripStatusWeight.Name = "toolStripStatusWeight"; + this.toolStripStatusWeight.Size = new System.Drawing.Size(29, 17); + this.toolStripStatusWeight.Text = "Вес:"; + // + // toolStripStatusLabelBodyColor + // + this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor"; + this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(36, 17); + this.toolStripStatusLabelBodyColor.Text = "Цвет:"; + // + // buttonRight + // + this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonRight.BackgroundImage = global::WarmlyShip.Properties.Resources.toright; + this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonRight.Location = new System.Drawing.Point(738, 375); + this.buttonRight.Name = "buttonRight"; + this.buttonRight.Size = new System.Drawing.Size(50, 50); + this.buttonRight.TabIndex = 3; + this.buttonRight.UseVisualStyleBackColor = true; + this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click); + // + // buttonUp + // + this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonUp.BackgroundImage = global::WarmlyShip.Properties.Resources.totop; + this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonUp.Location = new System.Drawing.Point(682, 319); + this.buttonUp.Name = "buttonUp"; + this.buttonUp.Size = new System.Drawing.Size(50, 50); + this.buttonUp.TabIndex = 4; + this.buttonUp.UseVisualStyleBackColor = true; + this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click); + // + // buttonLeft + // + this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonLeft.BackgroundImage = global::WarmlyShip.Properties.Resources.toleft; + this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonLeft.Location = new System.Drawing.Point(626, 375); + this.buttonLeft.Name = "buttonLeft"; + this.buttonLeft.Size = new System.Drawing.Size(50, 50); + this.buttonLeft.TabIndex = 5; + this.buttonLeft.UseVisualStyleBackColor = true; + this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click); + // + // buttonDown + // + this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonDown.BackgroundImage = global::WarmlyShip.Properties.Resources.todown; + this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonDown.Location = new System.Drawing.Point(682, 375); + this.buttonDown.Name = "buttonDown"; + this.buttonDown.Size = new System.Drawing.Size(50, 50); + this.buttonDown.TabIndex = 6; + this.buttonDown.UseVisualStyleBackColor = true; + this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click); + // + // ButtonCreate + // + this.ButtonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.ButtonCreate.Location = new System.Drawing.Point(12, 402); + this.ButtonCreate.Name = "ButtonCreate"; + this.ButtonCreate.Size = new System.Drawing.Size(75, 23); + this.ButtonCreate.TabIndex = 7; + this.ButtonCreate.Text = "Создать"; + this.ButtonCreate.UseVisualStyleBackColor = true; + this.ButtonCreate.Click += new System.EventHandler(this.ButtonCreate_Click); + // + // FormClass + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.ButtonCreate); + this.Controls.Add(this.buttonDown); + this.Controls.Add(this.buttonLeft); + this.Controls.Add(this.buttonUp); + this.Controls.Add(this.buttonRight); + this.Controls.Add(this.pictureBox); + this.Controls.Add(this.statusStrip); + this.Name = "FormClass"; + this.Text = "WarmlyShip"; + ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); + this.statusStrip.ResumeLayout(false); + this.statusStrip.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private PictureBox pictureBox; + private StatusStrip statusStrip; + private ToolStripStatusLabel toolStripStatusSpeed; + private ToolStripStatusLabel toolStripStatusWeight; + private ToolStripStatusLabel toolStripStatusLabelBodyColor; + private Button buttonRight; + private Button buttonUp; + private Button buttonLeft; + private Button buttonDown; + private Button ButtonCreate; + } +} \ No newline at end of file diff --git a/WarmlyShip/WarmlyShip/FormClass.cs b/WarmlyShip/WarmlyShip/FormClass.cs new file mode 100644 index 0000000..abaae2a --- /dev/null +++ b/WarmlyShip/WarmlyShip/FormClass.cs @@ -0,0 +1,59 @@ +namespace WarmlyShip +{ + public partial class FormClass : Form + { + private DrawingWarmlyShip _warmlyShip; + + public FormClass() + { + InitializeComponent(); + } + + private void Draw() + { + Bitmap bmp = new(pictureBox.Width, pictureBox.Height); + Graphics g = Graphics.FromImage(bmp); + _warmlyShip.DrawTransport(g); + pictureBox.Image = bmp; + } + + private void ButtonCreate_Click(object sender, EventArgs e) + { + Random random = new Random(); + _warmlyShip = new DrawingWarmlyShip(); + _warmlyShip.Init(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256))); + _warmlyShip.SetPosition(random.Next(10, 100), random.Next(10, 100), pictureBox.Width, pictureBox.Height); + toolStripStatusSpeed.Text = $": {_warmlyShip.warmlyShip?.Speed}"; + toolStripStatusWeight.Text = $": {_warmlyShip.warmlyShip?.Weight}"; + toolStripStatusLabelBodyColor.Text = $": {_warmlyShip.warmlyShip?.BodyColor}"; + Draw(); + } + + private void ButtonMove_Click(object sender, EventArgs e) + { + string name = ((Button)sender)?.Name ?? string.Empty; + switch (name) + { + case "buttonLeft": + _warmlyShip?.MoveTransport(Direction.Left); + break; + case "buttonUp": + _warmlyShip?.MoveTransport(Direction.Up); + break; + case "buttonRight": + _warmlyShip?.MoveTransport(Direction.Right); + break; + case "buttonDown": + _warmlyShip?.MoveTransport(Direction.Down); + break; + } + Draw(); + } + + private void PictureBox_Resize(object sender, EventArgs e) + { + _warmlyShip?.ChangeBorders(pictureBox.Width, pictureBox.Height); + Draw(); + } + } +} \ No newline at end of file diff --git a/WarmlyShip/WarmlyShip/FormClass.resx b/WarmlyShip/WarmlyShip/FormClass.resx new file mode 100644 index 0000000..2c0949d --- /dev/null +++ b/WarmlyShip/WarmlyShip/FormClass.resx @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 17, 17 + + \ No newline at end of file diff --git a/WarmlyShip/WarmlyShip/Program.cs b/WarmlyShip/WarmlyShip/Program.cs index 341c406..a894d54 100644 --- a/WarmlyShip/WarmlyShip/Program.cs +++ b/WarmlyShip/WarmlyShip/Program.cs @@ -11,7 +11,7 @@ namespace WarmlyShip // 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 FormClass()); } } } \ No newline at end of file diff --git a/WarmlyShip/WarmlyShip/Properties/Resources.Designer.cs b/WarmlyShip/WarmlyShip/Properties/Resources.Designer.cs new file mode 100644 index 0000000..b2e3217 --- /dev/null +++ b/WarmlyShip/WarmlyShip/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace WarmlyShip.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("WarmlyShip.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 todown { + get { + object obj = ResourceManager.GetObject("todown", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap toleft { + get { + object obj = ResourceManager.GetObject("toleft", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap toright { + get { + object obj = ResourceManager.GetObject("toright", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap totop { + get { + object obj = ResourceManager.GetObject("totop", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/WarmlyShip/WarmlyShip/Form1.resx b/WarmlyShip/WarmlyShip/Properties/Resources.resx similarity index 83% rename from WarmlyShip/WarmlyShip/Form1.resx rename to WarmlyShip/WarmlyShip/Properties/Resources.resx index 1af7de1..11295ff 100644 --- a/WarmlyShip/WarmlyShip/Form1.resx +++ b/WarmlyShip/WarmlyShip/Properties/Resources.resx @@ -117,4 +117,17 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\todown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\toleft.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\totop.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\toright.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/WarmlyShip/WarmlyShip/Resources/todown.png b/WarmlyShip/WarmlyShip/Resources/todown.png new file mode 100644 index 0000000000000000000000000000000000000000..074dc0003813b243413609b3c504b85e9b06db32 GIT binary patch literal 1298 zcmV+t1?~EYP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGf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y9_nyn#~UP&84D6Kpp9L?^+IJP;G| zgCH2=?VJ~9#Y>Sw4Gn(*{zIKkvBup200000NkvXXu0mjf1A7mQ4J1C7DF6Tf07*qo IM6N<$f~rs;>i_@% literal 0 HcmV?d00001 diff --git a/WarmlyShip/WarmlyShip/Resources/toleft.png b/WarmlyShip/WarmlyShip/Resources/toleft.png new file mode 100644 index 0000000000000000000000000000000000000000..648ca1405e13202768dbf0c0ff27c10c58522cd9 GIT binary patch literal 1298 zcmV+t1?~EYP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGf6951U69E94 zoEQKA1c^yRK~!i%&6-Q7RaF?rZ=puMC`?78S*c{c2Z;k8MBvN{F({*nN747?>#TiFfA|gdx@WKb zt=G5K_pSR#UmlHt`7j42!gKHhi~w~Deus1L0~~|T;TrTzqhK|hfP0CYgf;LKBq?PC z#=*O=5{6n()30z8z6N{wI@|;`5=O%Wcmd`?z0rTcUf2ddTTq1t!+UTWq6e?Sc9;c^ zLc8*}Ghi!daMbq)tcM|xRnNj1h!0(a74R5zDvezR7a;2Y0vxR@S_Do7E4~9Cz~hix zcE;r9ZBwmBIhe_2->3ebCVoUz7XEVIp57`(@MkOThOL2 zVZaX6&-+8YP3{Hj;&k^;(PVJ5)3yy3G?P1QY*M<)oSF(ZK>wcFh>f6aZgx*w&?t9Q zf8ZvS)6a+T)-9=xaG&rnXdOE(sFxMmGXLlfn@bw+nJA18jzEgu2H*b^9ykDcs`L+@ zZE_qBR4d~hjcJe~oy=vhp0yT);z;Z?%AqQZ4{ZVKI#oO&gOT`vr^-$>1*$S$>5-yN z9Z%nq+Jhe`b0lu2s*P91Fh7CyzM;W}fy!XSEjv{j|0y&^R|YySftyecX}Gqk*)|}y zXCtXpb<6lr*jm_r9*W`cAwe4d3&eB@a!#8@Ee5|~5LA4~hnIaQsa_bbjH&(3Z%&~| zeMA6WMtXr}2R;|FdrDO@T2sai#lg+iyy!!M7D9x9^?U=m=qfZ5{Kh{%bTWlP-EPDK zQ^<^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ohw5Rt(SG6xsuU#8gXq zWmAce#%pMC!HUzy(^VNc=+XC!Hn_mz0oG*7s!HS4B8WbXZcSMww!vCu8TDuUJg)$p!7p2dOQLTidXfuiA((|ENO?AL>R@8Hnb z3I5S4v7UA-JG5>S#``vM8b2D&f_*!U`e+*HnKx{+Awl6pZsXNkplxOj#g8NRC=TaV zC{iPmPUPNG7J!MHw!LmcJ9+B&l#K_AUNRm#(oA5wV zRpGWM7i`RVM?Ts3kY7gpxL}8#psW(7>=OgYIB%$oXycskdfK#;XNBS>WhKKxYf2Tn zw;T+2*x01RXw&h6?Nl1;cZ1mM#6qjJO3Qtwxt+>;%_`kdBexNwpK-q9pplaQTTAsJ zt`A>($lce9nMEh(uz8TvK)EPA1{$JWN0xAkxr}+(UI>S3kqMwBZmYyGg56?DY*yJP zG3!*hPGDAvmqHIX$}?a*M5V(Za2ZS#JqCUOpMqt`5^6MV1A7mQ4J1C7DF6Tf07*qo IM6N<$g517qvH$=8 literal 0 HcmV?d00001 diff --git a/WarmlyShip/WarmlyShip/Resources/totop.png b/WarmlyShip/WarmlyShip/Resources/totop.png new file mode 100644 index 0000000000000000000000000000000000000000..02de3195ae52fc182b7a18d21c3993615d7e1dc7 GIT binary patch literal 1298 zcmV+t1?~EYP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGf6951U69E94 zoEQKA1b0b9K~!i%&6-KbjZqlKFPW#v6tXgA9u|fT64}WRW$4==AvOr5lx$2TDWxnd zEUZ|tkW339WS%}!#xiH74FBKjKG(h19nL-Px%a;R`o%f-eb0H${G8|gnxw+0yO=1( zi29AC6<00A67fh_`By|=5kxZti;#l9iH(9vLyPISNqiU7#q^sl zVu^YFOHkk)F;rArBLr)RI)94A!b=!WA#hBz6SWeH{dW-2~Yl7XWWQVR3Jor@%CLA5W`_Arc(EB>5@c?PQsFdB;C|ruhiU{4AhzO)M`A&c z0U>uDGv3M$)d;*;E3+FJ^U?`i<4`xWeB%x72yq*ME6&}6^5&2jD-f3vGUE#44~s%O z8JopP5vLKjIM|BD(*RrtbR+$59F;QO6rvH_`cPy$mlJw^Hi;N2Hf?ajZOF4>It>#( zvT6T-#M^X&d#bOB8GlQ#(1weUjhG^MpE6TF(uq+dJXFqjQ^-b)5xk3k6srNQ#+yPl zBBueqQ>aqoO~o2Po@*m=rjRY-StK0gYrLscBZwQ7Q)UsfjnV)_=)^@-P-v^<0yIgu zgbTSeO%`vW)IU8HE`cqxwUGu8t3(arPEpT)IFCBVx1&l5E&JSD`*_!eMA`3>?JB5>9QbWbCgQ9 zh{a+nQSppc2{IpxW@IE(L{0FTv6aw%MufhJMDW7`G7>5R%Gk*D7pE{sy9Gbq6(OR| zp~bdsXVy+K^3_||#h&i~NfS|VY~w=D##2zlgY2P!WF$oF`*!k|>|BQFy5K=BIBi6| zMO2(S1vc@KrR?;k=PkHBv=!*SlGm-a1N=Hy1k7zF`aBpusg8}RO6gr16eQZ zK&4K;6a^7IZ@Uw4*ew(x)&_H(fHF~WD<9X|!ac!64{=V|VF&n5IDmMul|=P;mZ?H4 zmVmOA#|Y!$I*+hVD3KF;jo`~+D>Bl0Ce8}h3ZI0y9Pn@Yp%EtM8yg1|L2&w%4Y-$iQeQ&Nt~6r+edT~_HCI3`A!f?;~IEgoDwnr zup^cF1J$OHze^KvlmGw#07*qoM6N<$f{YBKqI>TE0000enable + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file From 993e92ab6cfca9ca8ecee80d19c6acae5a4a7431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=20=D0=91=D0=BE=D0=BD=D0=B4=D0=B0?= =?UTF-8?q?=D1=80=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Wed, 21 Sep 2022 00:19:27 +0400 Subject: [PATCH 2/5] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=B0=E2=84=961.=20?= =?UTF-8?q?=D0=9D=D0=B5=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=B5=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=BF=D1=80=D0=B5=D0=BF=D0=BE=D0=B4=D0=B0=D0=B2=D0=B0?= =?UTF-8?q?=D1=82=D0=B5=D0=BB=D0=B5=D0=BC.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs b/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs index b8d7f9f..b942956 100644 --- a/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs +++ b/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs @@ -24,8 +24,9 @@ namespace WarmlyShip public void SetPosition(int x, int y, int width, int height) { - _startPosX = x; - _startPosY = y; + Random random = new Random(); + _startPosX = x < 0 || x > width ? random.Next(0, width) : x; + _startPosY = y < 0 || y > height ? random.Next(0, height) : y; _pictureWidth = width; _pictureHeight = height; } From 74cc61815ce0c710e18e1fd3aa1670e580202f39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=20=D0=91=D0=BE=D0=BD=D0=B4=D0=B0?= =?UTF-8?q?=D1=80=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Wed, 21 Sep 2022 09:47:59 +0400 Subject: [PATCH 3/5] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=BD=D0=BD=D0=BE=20=D0=BF=D1=80=D0=B5=D0=BF=D0=BE=D0=B4=D0=BE?= =?UTF-8?q?=D0=BC.=20=D0=9D=D0=B5=20pull=20request?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs | 5 +++-- WarmlyShip/WarmlyShip/FormClass.cs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs b/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs index b942956..b131644 100644 --- a/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs +++ b/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs @@ -24,9 +24,10 @@ namespace WarmlyShip public void SetPosition(int x, int y, int width, int height) { + if (width < _warmlyShipWidth || height < _warmlyShipHeight) return; Random random = new Random(); - _startPosX = x < 0 || x > width ? random.Next(0, width) : x; - _startPosY = y < 0 || y > height ? random.Next(0, height) : y; + _startPosX = x < 0 || x + _warmlyShipWidth > width ? random.Next(0, width - _warmlyShipWidth) : x; + _startPosY = y < 0 || y + _warmlyShipHeight > height ? random.Next(0, height - _warmlyShipHeight) : y; _pictureWidth = width; _pictureHeight = height; } diff --git a/WarmlyShip/WarmlyShip/FormClass.cs b/WarmlyShip/WarmlyShip/FormClass.cs index abaae2a..23e86ce 100644 --- a/WarmlyShip/WarmlyShip/FormClass.cs +++ b/WarmlyShip/WarmlyShip/FormClass.cs @@ -22,7 +22,7 @@ namespace WarmlyShip Random random = new Random(); _warmlyShip = new DrawingWarmlyShip(); _warmlyShip.Init(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256))); - _warmlyShip.SetPosition(random.Next(10, 100), random.Next(10, 100), pictureBox.Width, pictureBox.Height); + _warmlyShip.SetPosition(random.Next(pictureBox.Width - 150, pictureBox.Width - 125), random.Next(pictureBox.Height - 150, pictureBox.Height - 50), pictureBox.Width, pictureBox.Height); toolStripStatusSpeed.Text = $": {_warmlyShip.warmlyShip?.Speed}"; toolStripStatusWeight.Text = $": {_warmlyShip.warmlyShip?.Weight}"; toolStripStatusLabelBodyColor.Text = $": {_warmlyShip.warmlyShip?.BodyColor}"; From 367ad52b343bf5dbcc1812abf4de4f1d415465e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=20=D0=91=D0=BE=D0=BD=D0=B4=D0=B0?= =?UTF-8?q?=D1=80=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Wed, 21 Sep 2022 10:51:48 +0400 Subject: [PATCH 4/5] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=B0=E2=84=961.=20?= =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=B5=D0=BD=D0=BD=D0=B0?= =?UTF-8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarmlyShip/WarmlyShip/FormClass.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WarmlyShip/WarmlyShip/FormClass.cs b/WarmlyShip/WarmlyShip/FormClass.cs index 23e86ce..abaae2a 100644 --- a/WarmlyShip/WarmlyShip/FormClass.cs +++ b/WarmlyShip/WarmlyShip/FormClass.cs @@ -22,7 +22,7 @@ namespace WarmlyShip Random random = new Random(); _warmlyShip = new DrawingWarmlyShip(); _warmlyShip.Init(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256))); - _warmlyShip.SetPosition(random.Next(pictureBox.Width - 150, pictureBox.Width - 125), random.Next(pictureBox.Height - 150, pictureBox.Height - 50), pictureBox.Width, pictureBox.Height); + _warmlyShip.SetPosition(random.Next(10, 100), random.Next(10, 100), pictureBox.Width, pictureBox.Height); toolStripStatusSpeed.Text = $": {_warmlyShip.warmlyShip?.Speed}"; toolStripStatusWeight.Text = $": {_warmlyShip.warmlyShip?.Weight}"; toolStripStatusLabelBodyColor.Text = $": {_warmlyShip.warmlyShip?.BodyColor}"; From f282067ee40f8eaa89670f004b631580c64ba96c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=20=D0=91=D0=BE=D0=BD=D0=B4=D0=B0?= =?UTF-8?q?=D1=80=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Fri, 30 Sep 2022 18:58:18 +0400 Subject: [PATCH 5/5] =?UTF-8?q?=D0=9F=D0=BE=D1=81=D0=BB=D0=B5=D0=B4=D0=BD?= =?UTF-8?q?=D0=B8=D0=B9=20=D0=BA=D0=BE=D0=BC=D0=BC=D0=B8=D1=82.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs | 5 +++++ WarmlyShip/WarmlyShip/EntityWarmlyShip.cs | 1 + 2 files changed, 6 insertions(+) diff --git a/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs b/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs index b131644..36a30b4 100644 --- a/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs +++ b/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs @@ -16,12 +16,14 @@ namespace WarmlyShip private readonly int _warmlyShipWidth = 125; //Ширина отрисовки корабля private readonly int _warmlyShipHeight = 50; //Высота отрисовки корабля + //Инициализация public void Init(int speed, float weight, Color bodyColor) { warmlyShip = new EntityWarmlyShip(); warmlyShip.Init(speed, weight, bodyColor); } + //Начальные коордитанты public void SetPosition(int x, int y, int width, int height) { if (width < _warmlyShipWidth || height < _warmlyShipHeight) return; @@ -32,6 +34,7 @@ namespace WarmlyShip _pictureHeight = height; } + //Движение транспорта по координатам public void MoveTransport(Direction direction) { if (!_pictureWidth.HasValue || !_pictureHeight.HasValue) return; @@ -52,6 +55,7 @@ namespace WarmlyShip } } + //Отрисовка транспорта public void DrawTransport(Graphics g) { if (_startPosX < 0 || _startPosY < 0 || !_pictureHeight.HasValue || !_pictureWidth.HasValue) @@ -84,6 +88,7 @@ namespace WarmlyShip g.DrawEllipse(new(Color.Blue, 2), _startPosX + _warmlyShipWidth * 2 / 5 + 2.5f, _startPosY + 25, 20, 20); } + //Изменение границ отрисовки public void ChangeBorders(int width, int height) { _pictureWidth = width; diff --git a/WarmlyShip/WarmlyShip/EntityWarmlyShip.cs b/WarmlyShip/WarmlyShip/EntityWarmlyShip.cs index 29576fb..4fb169a 100644 --- a/WarmlyShip/WarmlyShip/EntityWarmlyShip.cs +++ b/WarmlyShip/WarmlyShip/EntityWarmlyShip.cs @@ -13,6 +13,7 @@ namespace WarmlyShip public Color BodyColor { get; private set; } //Цвет public float Step => Speed * 100 / Weight; //Шаг при перемещении + //Инициализация public void Init(int speed, float weight, Color bodyColor) { Random random = new Random();