diff --git a/AirPlaneWithRadar/AirPlaneWithRadar/DrawingPlain.cs b/AirPlaneWithRadar/AirPlaneWithRadar/DrawingPlain.cs index 90f15b4..0b0acdd 100644 --- a/AirPlaneWithRadar/AirPlaneWithRadar/DrawingPlain.cs +++ b/AirPlaneWithRadar/AirPlaneWithRadar/DrawingPlain.cs @@ -16,11 +16,11 @@ namespace AirPlaneWithRadar private int? pictureHeight = null; protected readonly int plainWidth = 120; protected readonly int plainHeight =70; - public void Init (int speed, float weight, Color bodycolor) + public DrawingPlain(int speed, float weight, Color bodycolor) { - Plain = new EntetyPlain (); - Plain.Init (speed, weight, bodycolor); + Plain = new EntetyPlain(speed, weight, bodycolor); } + public void setPosition(int x,int y,int width,int height) { if (x + plainWidth > width || y + plainHeight > height || plainHeight > height || plainWidth > width || x <0 || y<0) @@ -66,27 +66,37 @@ namespace AirPlaneWithRadar } Pen pen = new Pen(Color.Black); - + + g.DrawRectangle(pen, startPosX, startPosY, 20, 30); g.DrawRectangle(pen, startPosX, startPosY + 30, 100, 30); g.DrawRectangle(pen, startPosX+100, startPosY + 40, 20, 15); - + //koleso1 g.DrawRectangle(pen, startPosX + 30, startPosY + 60, 5, 10); g.DrawEllipse(pen, startPosX+28, startPosY+70, 9, 9); - + //koleso2 g.DrawRectangle(pen, startPosX + 80, startPosY + 60, 5, 10); g.DrawEllipse(pen, startPosX + 78, startPosY + 70, 9, 9); - + + //Korpys Brush br = new SolidBrush(Plain?.BodyColor ?? Color.Black); g.FillRectangle(br, startPosX+3, startPosY + 33, 94, 24); g.FillRectangle(br, startPosX+1, startPosY+1, 19, 29); + + //krilya Brush brWings = new SolidBrush(Color.Black); g.FillRectangle(brWings, startPosX + 30, startPosY + 40, 40, 8); + + //cabina Brush brCabine = new SolidBrush(Color.Blue); g.FillRectangle(brCabine, startPosX + 101, startPosY + 41, 19, 14); + + + + } public void ChangeBorders(int width, int height) diff --git a/AirPlaneWithRadar/AirPlaneWithRadar/EntetyPlain.cs b/AirPlaneWithRadar/AirPlaneWithRadar/EntetyPlain.cs index 1694c17..48af56c 100644 --- a/AirPlaneWithRadar/AirPlaneWithRadar/EntetyPlain.cs +++ b/AirPlaneWithRadar/AirPlaneWithRadar/EntetyPlain.cs @@ -14,13 +14,14 @@ namespace AirPlaneWithRadar public Color BodyColor { get; private set; } public float Step => Speed * 100 / Weight; - public void Init (int speed, float weight, Color bodycolor) + public EntetyPlain(int speed, float weight, Color bodyColor) { Random rd = new Random(); - - Speed = speed <= 0 ? rd.Next(50,150):speed; - Weight = weight <= 0 ? rd.Next(40, 70) :weight; - BodyColor = bodycolor; + Speed = speed <= 0 ? rd.Next(50, 150) : speed; + Weight = weight <= 0 ? rd.Next(40, 70) : weight; + BodyColor = bodyColor; } + + } } diff --git a/AirPlaneWithRadar/AirPlaneWithRadar/FormPlain.cs b/AirPlaneWithRadar/AirPlaneWithRadar/FormPlain.cs index 52158d0..25cdcc4 100644 --- a/AirPlaneWithRadar/AirPlaneWithRadar/FormPlain.cs +++ b/AirPlaneWithRadar/AirPlaneWithRadar/FormPlain.cs @@ -22,9 +22,9 @@ namespace AirPlaneWithRadar private void ButtonCreate_Click(object sender, EventArgs e) { Random rnd = new(); - _plain = new DrawingPlain(); + _plain = new DrawingPlain(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); - _plain.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); + _plain.setPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxPlain.Width, pictureBoxPlain.Height); toolStripStatusLabelSpeed.Text = $"Скорость: {_plain.Plain.Speed}"; toolStripStatusLabelWeight.Text = $"Вес: {_plain.Plain.Weight}";