diff --git a/ProjectPlane/ProjectPlane/DrawningPlane.cs b/ProjectPlane/ProjectPlane/DrawningPlane.cs
index 11ad743..2e28c8c 100644
--- a/ProjectPlane/ProjectPlane/DrawningPlane.cs
+++ b/ProjectPlane/ProjectPlane/DrawningPlane.cs
@@ -36,15 +36,7 @@ namespace ProjectPlane
///
/// Высота отрисовки самолета
///
- private readonly int _planeHeight = 50;
- ///
- /// Левый край
- ///
- private readonly int _minX = 5;
- ///
- /// Верхний край
- ///
- private readonly int _minY = 40;
+ private readonly int _planeHeight = 80;
///
/// Инициализация свойств
///
@@ -65,14 +57,18 @@ namespace ProjectPlane
/// Высота картинки
public void SetPosition(int x, int y, int width, int height)
{
- if (x >= _minX && x <= width && y >= _minY && y <= height)
+ if (x < 0 || x + _planeWidth >= width)
{
- _startPosX = x;
- _startPosY = y;
- _pictureWidth = width;
- _pictureHeight = height;
+ return;
}
- else SetPosition(_minX, _minY, width, height);
+ if (y < 0 || y + _planeHeight >= height)
+ {
+ return;
+ }
+ _startPosX = x;
+ _startPosY = y;
+ _pictureWidth = width;
+ _pictureHeight = height;
}
///
/// Изменение направления пермещения
@@ -102,12 +98,12 @@ namespace ProjectPlane
break;
//вверх
case Direction.Up:
- if (_startPosY - Plane.Step > 35)
+ if (_startPosY - Plane.Step > 0)
{
_startPosY -= Plane.Step;
}
break;
- break;
+
//вниз
case Direction.Down:
if (_startPosY + _planeHeight + Plane.Step < _pictureHeight)
@@ -131,46 +127,46 @@ namespace ProjectPlane
//границы самолета
Pen pen = new(Color.Black);
- g.DrawEllipse(pen, _startPosX, _startPosY, 20, 20);
+ g.DrawEllipse(pen, _startPosX, _startPosY + 20, 20, 20);
- g.DrawRectangle(pen, _startPosX + 8, _startPosY, 100, 20);
+ g.DrawRectangle(pen, _startPosX + 8, _startPosY + 20, 100, 20);
Point[] Triangle0 = new Point[3];
- Triangle0[0].X = Convert.ToInt32(_startPosX + 108); Triangle0[0].Y = Convert.ToInt32(_startPosY - 2);
- Triangle0[1].X = Convert.ToInt32(_startPosX + 125); Triangle0[1].Y = Convert.ToInt32(_startPosY + 10);
- Triangle0[2].X = Convert.ToInt32(_startPosX + 108); Triangle0[2].Y = Convert.ToInt32(_startPosY + 10);
+ Triangle0[0].X = Convert.ToInt32(_startPosX + 108); Triangle0[0].Y = Convert.ToInt32(_startPosY + 18);
+ Triangle0[1].X = Convert.ToInt32(_startPosX + 125); Triangle0[1].Y = Convert.ToInt32(_startPosY + 30);
+ Triangle0[2].X = Convert.ToInt32(_startPosX + 108); Triangle0[2].Y = Convert.ToInt32(_startPosY + 30);
g.DrawPolygon(pen, Triangle0);
Point[] Triangle1 = new Point[3];
- Triangle1[0].X = Convert.ToInt32(_startPosX + 108); Triangle1[0].Y = Convert.ToInt32(_startPosY + 10);
- Triangle1[1].X = Convert.ToInt32(_startPosX + 125); Triangle1[1].Y = Convert.ToInt32(_startPosY + 10);
- Triangle1[2].X = Convert.ToInt32(_startPosX + 108); Triangle1[2].Y = Convert.ToInt32(_startPosY + 22);
+ Triangle1[0].X = Convert.ToInt32(_startPosX + 108); Triangle1[0].Y = Convert.ToInt32(_startPosY + 30);
+ Triangle1[1].X = Convert.ToInt32(_startPosX + 125); Triangle1[1].Y = Convert.ToInt32(_startPosY + 30);
+ Triangle1[2].X = Convert.ToInt32(_startPosX + 108); Triangle1[2].Y = Convert.ToInt32(_startPosY + 42);
g.DrawPolygon(pen, Triangle1);
-
+
Point[] Triangle = new Point[3];
- Triangle[0].X = Convert.ToInt32(_startPosX + 5); Triangle[0].Y = Convert.ToInt32(_startPosY);
- Triangle[1].X = Convert.ToInt32(_startPosX + 5); Triangle[1].Y = Convert.ToInt32(_startPosY - 20);
- Triangle[2].X = Convert.ToInt32(_startPosX + 35); Triangle[2].Y = Convert.ToInt32(_startPosY);
+ Triangle[0].X = Convert.ToInt32(_startPosX + 5); Triangle[0].Y = Convert.ToInt32(_startPosY + 20);
+ Triangle[1].X = Convert.ToInt32(_startPosX + 5); Triangle[1].Y = Convert.ToInt32(_startPosY);
+ Triangle[2].X = Convert.ToInt32(_startPosX + 35); Triangle[2].Y = Convert.ToInt32(_startPosY + 20);
g.DrawPolygon(pen, Triangle);
////корпус
Brush br = new SolidBrush(Plane?.BodyColor ?? Color.Black);
- g.FillEllipse(br, _startPosX, _startPosY, 20, 20);
+ g.FillEllipse(br, _startPosX, _startPosY + 20, 20, 20);
- g.FillRectangle(br, _startPosX + 8, _startPosY, 100, 20);
+ g.FillRectangle(br, _startPosX + 8, _startPosY + 20, 100, 20);
Point[] Triangle2 = new Point[3];
- Triangle2[0].X = Convert.ToInt32(_startPosX + 5); Triangle2[0].Y = Convert.ToInt32(_startPosY);
- Triangle2[1].X = Convert.ToInt32(_startPosX + 5); Triangle2[1].Y = Convert.ToInt32(_startPosY - 20);
- Triangle2[2].X = Convert.ToInt32(_startPosX + 35); Triangle2[2].Y = Convert.ToInt32(_startPosY);
+ Triangle2[0].X = Convert.ToInt32(_startPosX + 5); Triangle2[0].Y = Convert.ToInt32(_startPosY + 20);
+ Triangle2[1].X = Convert.ToInt32(_startPosX + 5); Triangle2[1].Y = Convert.ToInt32(_startPosY); //the highest point
+ Triangle2[2].X = Convert.ToInt32(_startPosX + 35); Triangle2[2].Y = Convert.ToInt32(_startPosY + 20);
g.FillPolygon(br, Triangle2);
Point[] Triangle4 = new Point[3];
- Triangle4[0].X = Convert.ToInt32(_startPosX + 108); Triangle4[0].Y = Convert.ToInt32(_startPosY + 10);
- Triangle4[1].X = Convert.ToInt32(_startPosX + 125); Triangle4[1].Y = Convert.ToInt32(_startPosY + 10);
- Triangle4[2].X = Convert.ToInt32(_startPosX + 108); Triangle4[2].Y = Convert.ToInt32(_startPosY + 22);
+ Triangle4[0].X = Convert.ToInt32(_startPosX + 108); Triangle4[0].Y = Convert.ToInt32(_startPosY + 30);
+ Triangle4[1].X = Convert.ToInt32(_startPosX + 125); Triangle4[1].Y = Convert.ToInt32(_startPosY + 30);
+ Triangle4[2].X = Convert.ToInt32(_startPosX + 108); Triangle4[2].Y = Convert.ToInt32(_startPosY + 42);
g.FillPolygon(br, Triangle4);
// window
@@ -179,26 +175,26 @@ namespace ProjectPlane
Brush brBlack = new SolidBrush(Color.Black);
Point[] Triangle3 = new Point[3];
- Triangle3[0].X = Convert.ToInt32(_startPosX + 108); Triangle3[0].Y = Convert.ToInt32(_startPosY - 2);
- Triangle3[1].X = Convert.ToInt32(_startPosX + 125); Triangle3[1].Y = Convert.ToInt32(_startPosY + 10);
- Triangle3[2].X = Convert.ToInt32(_startPosX + 108); Triangle3[2].Y = Convert.ToInt32(_startPosY + 10);
+ Triangle3[0].X = Convert.ToInt32(_startPosX + 108); Triangle3[0].Y = Convert.ToInt32(_startPosY + 18);
+ Triangle3[1].X = Convert.ToInt32(_startPosX + 125); Triangle3[1].Y = Convert.ToInt32(_startPosY + 30);
+ Triangle3[2].X = Convert.ToInt32(_startPosX + 108); Triangle3[2].Y = Convert.ToInt32(_startPosY + 30);
g.FillPolygon(brBlue, Triangle3);
- g.DrawLine(pen, _startPosX + 37, _startPosY + 20, _startPosX + 37, _startPosY + 25);
- g.DrawLine(pen, _startPosX + 32, _startPosY + 25, _startPosX + 40, _startPosY + 25);
- g.FillRectangle(brBlack, _startPosX + 32, _startPosY + 25, 3, 3);
- g.FillRectangle(brBlack, _startPosX + 39, _startPosY + 25, 3, 3);
+ g.DrawLine(pen, _startPosX + 37, _startPosY + 40, _startPosX + 37, _startPosY + 45);
+ g.DrawLine(pen, _startPosX + 32, _startPosY + 45, _startPosX + 40, _startPosY + 45);
+ g.FillRectangle(brBlack, _startPosX + 32, _startPosY + 45, 3, 3);
+ g.FillRectangle(brBlack, _startPosX + 39, _startPosY + 45, 3, 3);
- g.DrawLine(pen, _startPosX + 102, _startPosY + 20, _startPosX + 102, _startPosY + 25);
- g.FillRectangle(brBlack, _startPosX + 101, _startPosY + 25, 3, 3);
+ g.DrawLine(pen, _startPosX + 102, _startPosY + 40, _startPosX + 102, _startPosY + 45);
+ g.FillRectangle(brBlack, _startPosX + 101, _startPosY + 45, 3, 3);
- g.FillRectangle(brBlack, _startPosX + 5, _startPosY - 2, 18, 7);
- g.FillEllipse(brBlack, _startPosX, _startPosY - 2, 7, 7);
- g.FillEllipse(brBlack, _startPosX + 20, _startPosY - 2, 7, 7);
+ g.FillRectangle(brBlack, _startPosX + 5, _startPosY + 18, 18, 7);
+ g.FillEllipse(brBlack, _startPosX, _startPosY + 18, 7, 7);
+ g.FillEllipse(brBlack, _startPosX + 20, _startPosY + 18, 7, 7);
- g.FillRectangle(brBlack, _startPosX + 41, _startPosY + 8, 42, 4);
- g.FillEllipse(brBlack, _startPosX + 39, _startPosY + 8, 4, 4);
- g.FillEllipse(brBlack, _startPosX + 81, _startPosY + 8, 4, 4);
+ g.FillRectangle(brBlack, _startPosX + 41, _startPosY + 28, 42, 4);
+ g.FillEllipse(brBlack, _startPosX + 39, _startPosY + 28, 4, 4);
+ g.FillEllipse(brBlack, _startPosX + 81, _startPosY + 28, 4, 4);
}
///
/// Смена границ формы отрисовки