Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
37f148d4bd | |||
7d560e85dd | |||
d8c21ff0a4 | |||
b66671fd10 | |||
e936b4d813 |
@ -36,15 +36,7 @@ namespace ProjectPlane
|
||||
/// <summary>
|
||||
/// Высота отрисовки самолета
|
||||
/// </summary>
|
||||
private readonly int _planeHeight = 50;
|
||||
/// <summary>
|
||||
/// Левый край
|
||||
/// </summary>
|
||||
private readonly int _minX = 5;
|
||||
/// <summary>
|
||||
/// Верхний край
|
||||
/// </summary>
|
||||
private readonly int _minY = 40;
|
||||
private readonly int _planeHeight = 80;
|
||||
/// <summary>
|
||||
/// Инициализация свойств
|
||||
/// </summary>
|
||||
@ -65,14 +57,18 @@ namespace ProjectPlane
|
||||
/// <param name="height">Высота картинки</param>
|
||||
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;
|
||||
}
|
||||
/// <summary>
|
||||
/// Изменение направления пермещения
|
||||
@ -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,75 +127,74 @@ 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
|
||||
|
||||
Brush brBlue = new SolidBrush(Color.LightBlue);
|
||||
|
||||
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);
|
||||
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.DrawRectangle(pen, _startPosX + 32, _startPosY + 25, 3, 3);
|
||||
g.DrawRectangle(pen, _startPosX + 39, _startPosY + 25, 3, 3);
|
||||
|
||||
g.DrawLine(pen, _startPosX + 102, _startPosY + 20, _startPosX + 102, _startPosY + 25);
|
||||
g.DrawRectangle(pen, _startPosX + 101, _startPosY + 25, 3, 3);
|
||||
|
||||
Brush brBlack = new SolidBrush(Color.Black);
|
||||
|
||||
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);
|
||||
Point[] Triangle3 = new Point[3];
|
||||
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.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.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 + 40, _startPosX + 102, _startPosY + 45);
|
||||
g.FillRectangle(brBlack, _startPosX + 101, _startPosY + 45, 3, 3);
|
||||
|
||||
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 + 28, 42, 4);
|
||||
g.FillEllipse(brBlack, _startPosX + 39, _startPosY + 28, 4, 4);
|
||||
g.FillEllipse(brBlack, _startPosX + 81, _startPosY + 28, 4, 4);
|
||||
}
|
||||
/// <summary>
|
||||
/// Смена границ формы отрисовки
|
||||
|
1
ProjectPlane/ProjectPlane/FormPlane.Designer.cs
generated
1
ProjectPlane/ProjectPlane/FormPlane.Designer.cs
generated
@ -146,6 +146,7 @@
|
||||
this.Controls.Add(this.pictureBoxPlane);
|
||||
this.Name = "FormPlane";
|
||||
this.Text = "Plane";
|
||||
this.SizeChanged += new System.EventHandler(this.PictureBoxCar_Resize);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlane)).EndInit();
|
||||
this.statusStrip1.ResumeLayout(false);
|
||||
this.statusStrip1.PerformLayout();
|
||||
|
Loading…
Reference in New Issue
Block a user