PIBD-11 Shipilov N.S. Seaplane LabWork01 Simple LabWork1 #1

Closed
NikitaShipilov wants to merge 5 commits from LabWork1 into main
2 changed files with 49 additions and 61 deletions
Showing only changes of commit 102b4cffde - Show all commits

View File

@ -19,9 +19,7 @@ public class DrawingSeaplane
private readonly int _drawingSeaplaneWidth = 190;
private readonly int _drawingSeaplaneHeight = 90;
private readonly int _drawingKeelHeight = 35;
private readonly int _drawingSeaplaneHeight = 85;
public void Init (int speed, double weight, Color bodyColor, Color additionalColor, bool floats, bool inflatableBoat)
{
@ -75,9 +73,9 @@ public class DrawingSeaplane
x = _pictureWidth.Value - _drawingSeaplaneWidth - _drawingSeaplaneWidth;
}
if (y - _drawingKeelHeight < 0)
if (y < 0)
{
y = _drawingKeelHeight;
y = 0;
}
else if (y - _drawingSeaplaneHeight >= _pictureHeight)
{
@ -106,7 +104,7 @@ public class DrawingSeaplane
return true;
//вверх
case DirectionType.Up:
if (_startPosY.Value - _drawingKeelHeight - EntitySeaplane.Step >= 0)
if (_startPosY.Value - EntitySeaplane.Step >= 0)
{
_startPosY -= (int)EntitySeaplane.Step;
}
@ -120,7 +118,7 @@ public class DrawingSeaplane
return true;
//вниз
case DirectionType.Down:
if (_startPosY.Value + EntitySeaplane.Step <= _pictureHeight.Value - _drawingSeaplaneHeight + _drawingKeelHeight)
if (_startPosY.Value + EntitySeaplane.Step <= _pictureHeight.Value - _drawingSeaplaneHeight)
{
_startPosY += (int)EntitySeaplane.Step;
}
@ -144,58 +142,58 @@ public class DrawingSeaplane
Brush brRed = new SolidBrush(Color.Red);
//границы самолета
g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 4, 20, 20);
g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 14, 20, 20);
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 15, 10, 10);
g.DrawRectangle(pen, _startPosX.Value + 170, _startPosY.Value + 15, 10, 10);
g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 4, 160, 30);
g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 34, 20, 20);
g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 44, 20, 20);
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 45, 10, 10);
g.DrawRectangle(pen, _startPosX.Value + 170, _startPosY.Value + 45, 10, 10);
g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 34, 160, 30);
Point[] pointsFaceTop = {
new Point(_startPosX.Value + 170, _startPosY.Value),
new Point(_startPosX.Value + 170, _startPosY.Value + 20),
new Point(_startPosX.Value + 190, _startPosY.Value + 20)
new Point(_startPosX.Value + 170, _startPosY.Value+30),
new Point(_startPosX.Value + 170, _startPosY.Value + 50),
new Point(_startPosX.Value + 190, _startPosY.Value + 50)
};
g.DrawPolygon(pen, pointsFaceTop);
Point[] pointsFaceBottom = {
new Point(_startPosX.Value + 170, _startPosY.Value + 40),
new Point(_startPosX.Value + 170, _startPosY.Value + 20),
new Point(_startPosX.Value + 190, _startPosY.Value + 20)
new Point(_startPosX.Value + 170, _startPosY.Value + 70),
new Point(_startPosX.Value + 170, _startPosY.Value + 50),
new Point(_startPosX.Value + 190, _startPosY.Value + 50)
};
g.DrawPolygon(pen, pointsFaceBottom);
Point[] pointsKeel = {
new Point(_startPosX.Value + 10, _startPosY.Value - 30),
new Point(_startPosX.Value + 10, _startPosY.Value + 5),
new Point(_startPosX.Value + 50, _startPosY.Value + 5)
new Point(_startPosX.Value + 10, _startPosY.Value),
new Point(_startPosX.Value + 10, _startPosY.Value+35),
new Point(_startPosX.Value + 50, _startPosY.Value+35)
};
g.DrawPolygon(pen, pointsKeel);
if (!EntitySeaplane.Floats)
{
// Рисуем переднее шасси с одним колесом
g.DrawEllipse(pen, _startPosX.Value + 140, _startPosY.Value + 45, 10, 10);
g.DrawEllipse(pen, _startPosX.Value + 140, _startPosY.Value + 75, 10, 10);
// Рисуем задние шасси с двумя колесами
g.DrawEllipse(pen, _startPosX.Value + 20, _startPosY.Value + 45, 10, 10);
g.DrawEllipse(pen, _startPosX.Value + 30, _startPosY.Value + 45, 10, 10);
g.DrawEllipse(pen, _startPosX.Value + 20, _startPosY.Value + 75, 10, 10);
g.DrawEllipse(pen, _startPosX.Value + 30, _startPosY.Value + 75, 10, 10);
// Рисуем ногу переднего шасси
g.DrawLine(pen, _startPosX.Value + 145, _startPosY.Value + 35, _startPosX.Value + 145, _startPosY.Value + 50);
g.DrawLine(pen, _startPosX.Value + 145, _startPosY.Value + 65, _startPosX.Value + 145, _startPosY.Value + 80);
// Рисуем ноги заднего шасси
g.DrawLine(pen, _startPosX.Value + 30, _startPosY.Value + 35, _startPosX.Value + 30, _startPosY.Value + 50);
g.DrawLine(pen, _startPosX.Value + 30, _startPosY.Value + 65, _startPosX.Value + 30, _startPosY.Value + 80);
}
// Рисуем триммера
g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value, 10, 10);
g.DrawEllipse(pen, _startPosX.Value+30, _startPosY.Value, 10, 10);
g.DrawRectangle(pen, _startPosX.Value+5, _startPosY.Value, 30, 10);
g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value+30, 10, 10);
g.DrawEllipse(pen, _startPosX.Value+30, _startPosY.Value+30, 10, 10);
g.DrawRectangle(pen, _startPosX.Value+5, _startPosY.Value+30, 30, 10);
// Рисуем крыло
g.DrawEllipse(pen, _startPosX.Value + 70, _startPosY.Value + 15, 6, 6);
g.DrawEllipse(pen, _startPosX.Value + 130, _startPosY.Value + 15, 6, 6);
g.DrawRectangle(pen, _startPosX.Value + 75, _startPosY.Value + 15, 60, 6);
g.DrawEllipse(pen, _startPosX.Value + 70, _startPosY.Value + 45, 6, 6);
g.DrawEllipse(pen, _startPosX.Value + 130, _startPosY.Value + 45, 6, 6);
g.DrawRectangle(pen, _startPosX.Value + 75, _startPosY.Value + 45, 60, 6);
// Закрашиваем носовую часть и киль
g.FillPolygon(additionalBrush, pointsFaceBottom);
@ -203,38 +201,38 @@ public class DrawingSeaplane
g.FillPolygon(additionalBrush, pointsKeel);
// Закрашиваем корпус
g.FillEllipse(bodyBrush, _startPosX.Value, _startPosY.Value + 4, 20, 20);
g.FillEllipse(bodyBrush, _startPosX.Value, _startPosY.Value + 14, 20, 20);
g.FillRectangle(bodyBrush, _startPosX.Value, _startPosY.Value + 15, 10, 10);
g.FillRectangle(bodyBrush, _startPosX.Value + 10, _startPosY.Value + 4, 160, 30);
g.FillEllipse(bodyBrush, _startPosX.Value, _startPosY.Value + 34, 20, 20);
g.FillEllipse(bodyBrush, _startPosX.Value, _startPosY.Value + 44, 20, 20);
g.FillRectangle(bodyBrush, _startPosX.Value, _startPosY.Value + 45, 10, 10);
g.FillRectangle(bodyBrush, _startPosX.Value + 10, _startPosY.Value + 34, 160, 30);
// Закрашиваем триммера
g.FillEllipse(brBlack, _startPosX.Value, _startPosY.Value, 10, 10);
g.FillEllipse(brBlack, _startPosX.Value + 30, _startPosY.Value, 10, 10);
g.FillRectangle(brBlack, _startPosX.Value + 5, _startPosY.Value, 30, 10);
g.FillEllipse(brBlack, _startPosX.Value, _startPosY.Value+30, 10, 10);
g.FillEllipse(brBlack, _startPosX.Value + 30, _startPosY.Value+30, 10, 10);
g.FillRectangle(brBlack, _startPosX.Value + 5, _startPosY.Value+30, 30, 10);
// Закрашиваем крыло
g.FillEllipse(brBlack, _startPosX.Value + 70, _startPosY.Value + 14, 6, 6);
g.FillEllipse(brBlack, _startPosX.Value + 130, _startPosY.Value + 14, 6, 6);
g.FillRectangle(brBlack, _startPosX.Value + 75, _startPosY.Value + 15, 60, 5);
g.FillEllipse(brBlack, _startPosX.Value + 70, _startPosY.Value + 44, 6, 6);
g.FillEllipse(brBlack, _startPosX.Value + 130, _startPosY.Value + 44, 6, 6);
g.FillRectangle(brBlack, _startPosX.Value + 75, _startPosY.Value + 45, 60, 5);
// Поплавки
if (EntitySeaplane.Floats)
{
g.DrawLine(pen, _startPosX.Value + 125, _startPosY.Value + 35, _startPosX.Value + 125, _startPosY.Value + 50);
g.DrawLine(pen, _startPosX.Value + 50, _startPosY.Value + 35, _startPosX.Value + 50, _startPosY.Value + 50);
g.FillEllipse(brBlack, _startPosX.Value + 40, _startPosY.Value + 45, 10, 10);
g.FillEllipse(brBlack, _startPosX.Value + 125, _startPosY.Value + 45, 10, 10);
g.FillRectangle(brBlack, _startPosX.Value + 45, _startPosY.Value + 45, 85, 10);
g.DrawLine(pen, _startPosX.Value + 125, _startPosY.Value + 65, _startPosX.Value + 125, _startPosY.Value + 80);
g.DrawLine(pen, _startPosX.Value + 50, _startPosY.Value + 65, _startPosX.Value + 50, _startPosY.Value + 80);
g.FillEllipse(brBlack, _startPosX.Value + 40, _startPosY.Value + 75, 10, 10);
g.FillEllipse(brBlack, _startPosX.Value + 125, _startPosY.Value + 75, 10, 10);
g.FillRectangle(brBlack, _startPosX.Value + 45, _startPosY.Value + 75, 85, 10);
}
// Надувная лодка
if (EntitySeaplane.InflatableBoat)
{
g.FillEllipse(brRed, _startPosX.Value, _startPosY.Value + 30, 8, 8);
g.FillEllipse(brRed, _startPosX.Value + 165, _startPosY.Value + 30, 8, 8);
g.FillRectangle(brRed, _startPosX.Value + 4, _startPosY.Value + 30, 165, 8);
g.FillEllipse(brRed, _startPosX.Value, _startPosY.Value + 60, 8, 8);
g.FillEllipse(brRed, _startPosX.Value + 165, _startPosY.Value + 60, 8, 8);
g.FillRectangle(brRed, _startPosX.Value + 4, _startPosY.Value + 60, 165, 8);
}
}

View File

@ -32,16 +32,6 @@ namespace ProjectSeaplane
pictureBoxSeaplane.Image = bmp;
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
}
private void buttonCreate_Click(object sender, EventArgs e)
{
Random random = new();
@ -52,7 +42,7 @@ namespace ProjectSeaplane
Convert.ToBoolean(random.Next(0,2)), Convert.ToBoolean(random.Next(0, 2))
);
_drawingSeaplane.SetPictureSize(pictureBoxSeaplane.Width, pictureBoxSeaplane.Height);
_drawingSeaplane.SetPosition(random.Next(10, 100), random.Next(10, 100));
_drawingSeaplane.SetPosition(pictureBoxSeaplane.Width - 190 - random.Next(10, 100), pictureBoxSeaplane.Height - 85 - random.Next(10, 100));
Draw();
}