From 874e2f1c633bf22b6be31c44189b32ae605ac5b0 Mon Sep 17 00:00:00 2001 From: Aleksandr4350 Date: Sun, 25 Feb 2024 00:00:17 +0400 Subject: [PATCH] over --- .../ProjectSportCar/DrawningAiroplane.cs | 77 ++++++++----------- .../ProjectSportCar/EntityAiroplane.cs | 14 +--- .../ProjectSportCar/FormAiroplane.cs | 3 +- 3 files changed, 39 insertions(+), 55 deletions(-) diff --git a/ProjectSportCar/ProjectSportCar/DrawningAiroplane.cs b/ProjectSportCar/ProjectSportCar/DrawningAiroplane.cs index 72ec0c1..1e63da0 100644 --- a/ProjectSportCar/ProjectSportCar/DrawningAiroplane.cs +++ b/ProjectSportCar/ProjectSportCar/DrawningAiroplane.cs @@ -33,11 +33,11 @@ public class DrawningAiroplane /// /// Ширина прорисовки /// - private readonly int _drawningAiroplaneWidth = 180; + private readonly int _drawningAiroplaneWidth = 160; /// /// Высота прорисовки /// - private readonly int _drawningaAiroplaneHeight = 110; + private readonly int _drawningaAiroplaneHeight = 80; /// /// Инициализация свойств @@ -48,12 +48,12 @@ public class DrawningAiroplane /// Дополнительный цвет /// Признак наличия бака /// Признак наличия радара - /// Признак наличия гоночной полосы + public void Init(int speed, double weight, Color bodyColor, Color - additionalColor, bool toplivbak, bool radar, bool sportLine) + additionalColor, bool toplivbak, bool radar) { EntityAiroplane = new EntityAiroplane(); - EntityAiroplane.Init(speed, weight, bodyColor, additionalColor, toplivbak, radar, sportLine); + EntityAiroplane.Init(speed, weight, bodyColor, additionalColor, toplivbak, radar); _pictureWidth = null; _pictureHeight = null; _startPosX = null; @@ -78,21 +78,20 @@ public bool SetPictureSize(int width, int height) if (_startPosX.HasValue && _startPosY.HasValue) { - if (_startPosX + _drawningAiroplaneWidth <= _pictureWidth) + if (_startPosX + _drawningAiroplaneWidth > _pictureWidth) { - _startPosX = 0; + _startPosX = _pictureWidth - _drawningAiroplaneWidth; } - if (_startPosY + _drawningaAiroplaneHeight <= _pictureWidth) + if (_startPosY + _drawningaAiroplaneHeight > _pictureWidth) { - _startPosY = 0; + _startPosY = _pictureHeight - _drawningaAiroplaneHeight; } } return true; } return false; - } /// /// Установка позиции @@ -194,65 +193,57 @@ public bool MoveTransport(DirectionType direction) SolidBrush(EntityAiroplane.AdditionalColor); + ////// //крыло верхнее самолета - g.DrawLine(pen, _startPosX.Value + 30, _startPosY.Value + 30, _startPosX.Value + 30, _startPosY.Value + 60); - g.DrawLine(pen, _startPosX.Value + 30, _startPosY.Value + 30, _startPosX.Value + 70, _startPosY.Value + 60); - g.DrawLine(pen, _startPosX.Value + 30, _startPosY.Value + 60, _startPosX.Value + 70, _startPosY.Value + 60); + g.DrawLine(pen, _startPosX.Value + 15, _startPosY.Value + 5, _startPosX.Value + 15, _startPosY.Value + 5); + g.DrawLine(pen, _startPosX.Value + 15, _startPosY.Value + 5, _startPosX.Value + 55, _startPosY.Value + 35); + g.DrawLine(pen, _startPosX.Value + 15, _startPosY.Value + 35, _startPosX.Value + 15, _startPosY.Value + 5); //задняя часть самолета полукруг - g.DrawArc(pen, _startPosX.Value + 20, _startPosY.Value + 60, 30,30,90,180); + g.DrawArc(pen, _startPosX.Value + 5, _startPosY.Value + 35, 30,30,90,180); //сзади - g.DrawEllipse(pen, _startPosX.Value + 25, _startPosY.Value + 55, 40,10); + g.DrawEllipse(pen, _startPosX.Value + 10, _startPosY.Value + 30, 40,10); Brush brbr = new SolidBrush(Color.Brown); - g.FillEllipse(brbr, _startPosX.Value + 25, _startPosY.Value + 55, 40,10); + g.FillEllipse(brbr, _startPosX.Value + 10, _startPosY.Value + 30, 40,10); //низ самолета - g.DrawLine(pen, _startPosX.Value + 31, _startPosY.Value + 90, _startPosX.Value + 150, _startPosY.Value + 90); - + g.DrawLine(pen, _startPosX.Value + 16, _startPosY.Value + 65, _startPosX.Value + 135, _startPosY.Value + 65); // треуголник спереди - g.DrawLine(pen, _startPosX.Value + 150, _startPosY.Value + 93, _startPosX.Value + 150, _startPosY.Value + 57); - g.DrawLine(pen, _startPosX.Value + 150, _startPosY.Value + 57, _startPosX.Value + 175, _startPosY.Value + 75); - g.DrawLine(pen, _startPosX.Value + 150, _startPosY.Value + 93, _startPosX.Value + 175, _startPosY.Value + 75); - g.DrawLine(pen, _startPosX.Value + 150, _startPosY.Value + 75, _startPosX.Value + 175, _startPosY.Value + 75); + g.DrawLine(pen, _startPosX.Value + 135, _startPosY.Value + 68, _startPosX.Value + 135, _startPosY.Value + 32); + g.DrawLine(pen, _startPosX.Value + 135, _startPosY.Value + 32, _startPosX.Value + 160, _startPosY.Value + 50); + g.DrawLine(pen, _startPosX.Value + 135, _startPosY.Value + 68, _startPosX.Value + 160, _startPosY.Value + 50); + g.DrawLine(pen, _startPosX.Value + 135, _startPosY.Value + 50, _startPosX.Value + 160, _startPosY.Value + 50); //вверх от тругольника до треугольника - g.DrawLine(pen, _startPosX.Value + 70, _startPosY.Value + 60, _startPosX.Value + 150, _startPosY.Value + 60); + g.DrawLine(pen, _startPosX.Value + 50, _startPosY.Value + 35, _startPosX.Value + 135, _startPosY.Value + 35); //крыло - g.DrawEllipse(pen, _startPosX.Value + 65, _startPosY.Value + 70, 70, 10); + g.DrawEllipse(pen, _startPosX.Value + 50, _startPosY.Value + 45, 70, 10); Brush brbl = new SolidBrush(Color.Black); - g.FillEllipse(brbl, _startPosX.Value + 65, _startPosY.Value + 70, 70, 10); + g.FillEllipse(brbl, _startPosX.Value + 50, _startPosY.Value + 45, 70, 10); //шасси - g.DrawLine(pen, _startPosX.Value + 50, _startPosY.Value + 90, _startPosX.Value + 50, _startPosY.Value + 100); - g.DrawLine(pen, _startPosX.Value + 135, _startPosY.Value + 90, _startPosX.Value + 135, _startPosY.Value + 100); - g.DrawLine(pen, _startPosX.Value + 40, _startPosY.Value + 100, _startPosX.Value + 60, _startPosY.Value + 100); - - g.DrawEllipse(pen, _startPosX.Value + 30, _startPosY.Value + 95, 10, 10); - g.DrawEllipse(pen, _startPosX.Value + 60, _startPosY.Value + 95, 10, 10); - g.DrawEllipse(pen, _startPosX.Value + 130, _startPosY.Value + 95, 10, 10); + g.DrawLine(pen, _startPosX.Value + 35, _startPosY.Value + 65, _startPosX.Value + 35, _startPosY.Value + 75); + g.DrawLine(pen, _startPosX.Value + 120, _startPosY.Value + 65, _startPosX.Value + 120, _startPosY.Value + 75); + g.DrawLine(pen, _startPosX.Value + 25, _startPosY.Value + 75, _startPosX.Value + 45, _startPosY.Value + 75); + g.DrawEllipse(pen, _startPosX.Value + 15, _startPosY.Value + 70, 10, 10); + g.DrawEllipse(pen, _startPosX.Value + 45, _startPosY.Value + 70, 10, 10); + g.DrawEllipse(pen, _startPosX.Value + 115, _startPosY.Value + 70, 10, 10); //топливный бак if (EntityAiroplane.Toplivbak) { - g.FillRectangle(additionalBrush, _startPosX.Value + 80,_startPosY.Value + 45, 30, 15); - //g.FillRectangle(additionalBrush, _startPosX.Value + 35,_startPosY.Value + 23, 35, 15); - //g.FillRectangle(additionalBrush, _startPosX.Value + 10,_startPosY.Value + 23, 20, 15); + g.FillRectangle(additionalBrush, _startPosX.Value + 65,_startPosY.Value + 20, 30, 15); } - + //Радар if (EntityAiroplane.Radar) { Brush brGreen = new SolidBrush(Color.LightGreen); - g.FillEllipse(brGreen, _startPosX.Value + 150, _startPosY.Value + 75, 10, 10); - g.DrawEllipse(pen, _startPosX.Value + 150, _startPosY.Value + 75, 10, 10); - } - - //спортивная линия - if (EntityAiroplane.SportLine) { - g.FillRectangle(additionalBrush, _startPosX.Value + 138, _startPosY.Value + 60, 10, 30); + g.FillEllipse(brGreen, _startPosX.Value + 135, _startPosY.Value + 50, 10, 10); + g.DrawEllipse(pen, _startPosX.Value + 135, _startPosY.Value + 50, 10, 10); } } } diff --git a/ProjectSportCar/ProjectSportCar/EntityAiroplane.cs b/ProjectSportCar/ProjectSportCar/EntityAiroplane.cs index d05727d..37ea974 100644 --- a/ProjectSportCar/ProjectSportCar/EntityAiroplane.cs +++ b/ProjectSportCar/ProjectSportCar/EntityAiroplane.cs @@ -1,11 +1,10 @@ namespace ProjectAiroplane; - public class EntityAiroplane { /// /// Скорость /// - public int Speed { get; private set; } + public int Speed { get; private set; } /// /// Вес /// @@ -27,11 +26,7 @@ public class EntityAiroplane // public bool Radar { get; private set; } /// - /// Признак (опция) наличия гоночной полосы - /// - public bool SportLine { get; private set; } - /// - /// Шаг перемещения автомобиля + /// Шаг перемещения самолета /// public double Step => Speed * 100 / Weight; /// @@ -43,8 +38,8 @@ public class EntityAiroplane /// /// /// - /// - public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool toplivbak, bool radar, bool sportLine) + + public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool toplivbak, bool radar) { Speed = speed; Weight = weight; @@ -52,7 +47,6 @@ public class EntityAiroplane AdditionalColor = additionalColor; Toplivbak = toplivbak; Radar = radar; - SportLine = sportLine; } } diff --git a/ProjectSportCar/ProjectSportCar/FormAiroplane.cs b/ProjectSportCar/ProjectSportCar/FormAiroplane.cs index 20afd35..9414b78 100644 --- a/ProjectSportCar/ProjectSportCar/FormAiroplane.cs +++ b/ProjectSportCar/ProjectSportCar/FormAiroplane.cs @@ -32,8 +32,7 @@ public partial class FormAiroplane : Form _drawningAiroplane.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)), - Convert.ToBoolean(random.Next(0, 2))); + Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2))); _drawningAiroplane.SetPictureSize(pictureBoxAiroplane.Width, pictureBoxAiroplane.Height); _drawningAiroplane.SetPosition(random.Next(10, 100), random.Next(10, 100));