PIbd-21 Potapov N.S. LabWork01 #1
@ -38,7 +38,7 @@ namespace ProjectStormtrooper
|
||||
/// <summary>
|
||||
/// Высота прорисовки
|
||||
/// </summary>
|
||||
private readonly int _stormtrooperHeight = 60;
|
||||
private readonly int _stormtrooperHeight = 110;
|
||||
/// <summary>
|
||||
/// Инициализация свойств
|
||||
/// </summary>
|
||||
@ -56,7 +56,6 @@ namespace ProjectStormtrooper
|
||||
Color additionalColor, bool rockets, bool bombs,
|
||||
int width, int height)
|
||||
{
|
||||
// TODO: продумать проверки
|
||||
if (width < _stormtrooperWidth && height < _stormtrooperHeight)
|
||||
{
|
||||
return false;
|
||||
@ -74,7 +73,6 @@ namespace ProjectStormtrooper
|
||||
/// <param name="y">Координата Y</param>
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
// TODO: изменение X и Y
|
||||
if (x < 0)
|
||||
{
|
||||
x = 0;
|
||||
@ -116,7 +114,6 @@ namespace ProjectStormtrooper
|
||||
break;
|
||||
// Вниз
|
||||
case DirectionType.Down:
|
||||
// TODO: Продумать логику
|
||||
if (_startPosY + _stormtrooperHeight + EntityStormtrooper.Step <= _pictureHeight)
|
||||
{
|
||||
_startPosY += (int)EntityStormtrooper.Step;
|
||||
@ -131,7 +128,6 @@ namespace ProjectStormtrooper
|
||||
break;
|
||||
// Вправо
|
||||
case DirectionType.Right:
|
||||
// TODO: Продумать логику
|
||||
if (_startPosX + _stormtrooperWidth + EntityStormtrooper.Step <= _pictureWidth)
|
||||
{
|
||||
_startPosX += (int)EntityStormtrooper.Step;
|
||||
@ -149,9 +145,183 @@ namespace ProjectStormtrooper
|
||||
{
|
||||
return;
|
||||
}
|
||||
// TODO: прорисовка объекта
|
||||
Brush brush = new SolidBrush(Color.Black);
|
||||
g.FillRectangle(brush, _startPosX, _startPosY, _stormtrooperWidth, _stormtrooperHeight);
|
||||
Pen penBlack = new Pen(Color.Black);
|
||||
Brush brushBlack = new SolidBrush(Color.Black);
|
||||
Brush brushBodyColor = new SolidBrush(EntityStormtrooper.BodyColor);
|
||||
Brush brushAdditionalColor = new SolidBrush(EntityStormtrooper.AdditionalColor);
|
||||
|
||||
|
||||
// Ширина фюзеляжа
|
||||
int bodyWidth = _stormtrooperHeight / 9;
|
||||
|
||||
// Рисуем бомбы
|
||||
if (EntityStormtrooper.Bombs)
|
||||
{
|
||||
Point[] pointsBombTail = {
|
||||
new Point(_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 8 + bodyWidth * 3 - 5,
|
||||
_startPosY + _stormtrooperHeight / 2 - bodyWidth / 2 - _stormtrooperHeight / 3 + bodyWidth / 2),
|
||||
new Point(_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 8 + bodyWidth * 3 + 5,
|
||||
_startPosY + _stormtrooperHeight / 2 - bodyWidth / 2 - _stormtrooperHeight / 3 + bodyWidth / 2 - 5),
|
||||
new Point(_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 8 + bodyWidth * 3 + 5,
|
||||
_startPosY + _stormtrooperHeight / 2 - bodyWidth / 2 - _stormtrooperHeight / 3 + bodyWidth / 2 + 5),
|
||||
new Point(_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 8 + bodyWidth * 3 - 5,
|
||||
_startPosY + _stormtrooperHeight / 2 - bodyWidth / 2 - _stormtrooperHeight / 3 + bodyWidth / 2)
|
||||
};
|
||||
|
||||
g.FillPolygon(brushAdditionalColor, pointsBombTail);
|
||||
g.DrawPolygon(penBlack, pointsBombTail);
|
||||
|
||||
for (int i = 0; i < pointsBombTail.Length; i++)
|
||||
{
|
||||
Point p = pointsBombTail[i];
|
||||
p.Y = _startPosY + _stormtrooperHeight - (p.Y - _startPosY);
|
||||
pointsBombTail[i] = p;
|
||||
}
|
||||
|
||||
g.FillPolygon(brushAdditionalColor, pointsBombTail);
|
||||
g.DrawPolygon(penBlack, pointsBombTail);
|
||||
|
||||
g.FillEllipse(brushAdditionalColor,
|
||||
_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 8,
|
||||
_startPosY + _stormtrooperHeight / 2 - bodyWidth / 2 - _stormtrooperHeight / 3,
|
||||
bodyWidth * 3,
|
||||
bodyWidth);
|
||||
g.DrawEllipse(penBlack,
|
||||
_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 8,
|
||||
_startPosY + _stormtrooperHeight / 2 - bodyWidth / 2 - _stormtrooperHeight / 3,
|
||||
bodyWidth * 3,
|
||||
bodyWidth);
|
||||
|
||||
g.FillEllipse(brushAdditionalColor,
|
||||
_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 8,
|
||||
_startPosY + _stormtrooperHeight / 2 - bodyWidth / 2 + _stormtrooperHeight / 3,
|
||||
bodyWidth * 3,
|
||||
bodyWidth);
|
||||
g.DrawEllipse(penBlack,
|
||||
_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 8,
|
||||
_startPosY + _stormtrooperHeight / 2 - bodyWidth / 2 + _stormtrooperHeight / 3,
|
||||
bodyWidth * 3,
|
||||
bodyWidth);
|
||||
}
|
||||
|
||||
// Рисуем ракеты
|
||||
if (EntityStormtrooper.Rockets)
|
||||
{
|
||||
int rocketWidth = bodyWidth * 4;
|
||||
int rocketHeight = bodyWidth / 2;
|
||||
|
||||
Brush brushRed = new SolidBrush(Color.Red);
|
||||
|
||||
|
||||
|
||||
Point[] rocketCockPit = {
|
||||
new Point(_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 5 - rocketHeight,
|
||||
_startPosY + _stormtrooperHeight / 2 - bodyWidth - bodyWidth / 2 + rocketHeight / 2),
|
||||
new Point(_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 5,
|
||||
_startPosY + _stormtrooperHeight / 2 - bodyWidth - bodyWidth / 2),
|
||||
new Point(_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 5,
|
||||
_startPosY + _stormtrooperHeight / 2 - bodyWidth - bodyWidth / 2 + rocketHeight)
|
||||
};
|
||||
|
||||
Point[] rocketTail = {
|
||||
new Point(_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 5 - rocketHeight + rocketWidth - 10,
|
||||
_startPosY + _stormtrooperHeight / 2 - bodyWidth - bodyWidth / 2 + rocketHeight / 2),
|
||||
new Point(_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 5 + rocketWidth,
|
||||
_startPosY + _stormtrooperHeight / 2 - bodyWidth * 2 + rocketHeight / 2),
|
||||
new Point(_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 5 + rocketWidth,
|
||||
_startPosY + _stormtrooperHeight / 2 - bodyWidth - bodyWidth / 2 + rocketHeight + bodyWidth / 2 - rocketHeight / 2)
|
||||
};
|
||||
|
||||
g.FillPolygon(brushRed, rocketCockPit);
|
||||
g.DrawPolygon(penBlack, rocketCockPit);
|
||||
|
||||
g.FillPolygon(brushBlack, rocketTail);
|
||||
g.DrawPolygon(penBlack, rocketTail);
|
||||
|
||||
for (int i = 0; i < rocketCockPit.Length; i++)
|
||||
{
|
||||
Point p = rocketCockPit[i];
|
||||
p.Y = _startPosY + _stormtrooperHeight - (p.Y - _startPosY);
|
||||
rocketCockPit[i] = p;
|
||||
}
|
||||
|
||||
for (int i = 0; i < rocketTail.Length; i++)
|
||||
{
|
||||
Point p = rocketTail[i];
|
||||
p.Y = _startPosY + _stormtrooperHeight - (p.Y - _startPosY);
|
||||
rocketTail[i] = p;
|
||||
}
|
||||
|
||||
g.FillPolygon(brushRed, rocketCockPit);
|
||||
g.DrawPolygon(penBlack, rocketCockPit);
|
||||
|
||||
g.FillPolygon(brushBlack, rocketTail);
|
||||
g.DrawPolygon(penBlack, rocketTail);
|
||||
|
||||
g.FillRectangle(brushAdditionalColor,
|
||||
_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 5,
|
||||
_startPosY + _stormtrooperHeight / 2 - bodyWidth - bodyWidth / 2,
|
||||
rocketWidth,
|
||||
rocketHeight);
|
||||
g.DrawRectangle(penBlack,
|
||||
_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 5,
|
||||
_startPosY + _stormtrooperHeight / 2 - bodyWidth - bodyWidth / 2,
|
||||
rocketWidth,
|
||||
rocketHeight);
|
||||
|
||||
g.FillRectangle(brushAdditionalColor,
|
||||
_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 5,
|
||||
_startPosY + _stormtrooperHeight / 2 + bodyWidth / 2 + bodyWidth / 2,
|
||||
rocketWidth,
|
||||
rocketHeight);
|
||||
g.DrawRectangle(penBlack,
|
||||
_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 5,
|
||||
_startPosY + _stormtrooperHeight / 2 + bodyWidth / 2 + bodyWidth / 2,
|
||||
rocketWidth,
|
||||
rocketHeight);
|
||||
}
|
||||
|
||||
|
||||
// Рисуем нос
|
||||
|
||||
Point[] pointsCockPit = {
|
||||
new Point(_startPosX, _startPosY + _stormtrooperHeight / 2),
|
||||
new Point(_startPosX + _stormtrooperWidth / 8, _startPosY + _stormtrooperHeight / 2 - bodyWidth / 2),
|
||||
new Point(_startPosX + _stormtrooperWidth / 8, _startPosY + _stormtrooperHeight / 2 + bodyWidth / 2)
|
||||
};
|
||||
|
||||
g.FillPolygon(brushBlack, pointsCockPit);
|
||||
|
||||
// Рисуем крылья
|
||||
|
||||
Point[] pointsWings = {
|
||||
new Point(_startPosX + _stormtrooperWidth / 2, _startPosY),
|
||||
new Point(_startPosX + _stormtrooperWidth / 2 + _stormtrooperWidth / 15, _startPosY),
|
||||
new Point(_startPosX + _stormtrooperWidth / 2 + _stormtrooperWidth / 6, _startPosY + _stormtrooperHeight / 2),
|
||||
new Point(_startPosX + _stormtrooperWidth / 2 + _stormtrooperWidth / 15, _startPosY + _stormtrooperHeight),
|
||||
new Point(_startPosX + _stormtrooperWidth / 2 , _startPosY + _stormtrooperHeight)
|
||||
};
|
||||
|
||||
g.FillPolygon(brushBodyColor, pointsWings);
|
||||
g.DrawPolygon(penBlack, pointsWings);
|
||||
|
||||
// Рисуем хвостовое оперение
|
||||
|
||||
Point[] pointsTail = {
|
||||
new Point(_startPosX + _stormtrooperWidth, _startPosY + _stormtrooperHeight / 2 - _stormtrooperHeight / 3),
|
||||
new Point(_startPosX + _stormtrooperWidth - _stormtrooperWidth / 8, _startPosY + _stormtrooperHeight / 2 - _stormtrooperHeight / 8),
|
||||
new Point(_startPosX + _stormtrooperWidth - _stormtrooperWidth / 8, _startPosY + _stormtrooperHeight / 2 + _stormtrooperHeight / 8),
|
||||
new Point(_startPosX + _stormtrooperWidth, _startPosY + _stormtrooperHeight / 2 + _stormtrooperHeight / 3)
|
||||
|
||||
};
|
||||
|
||||
g.FillPolygon(brushBodyColor, pointsTail);
|
||||
g.DrawPolygon(penBlack, pointsTail);
|
||||
|
||||
// Рисуем фюзеляж
|
||||
|
||||
g.FillRectangle(brushBodyColor, _startPosX + _stormtrooperWidth / 8, _startPosY + _stormtrooperHeight / 2 - bodyWidth / 2, _stormtrooperWidth - _stormtrooperWidth / 8, bodyWidth);
|
||||
g.DrawRectangle(penBlack, _startPosX + _stormtrooperWidth / 8, _startPosY + _stormtrooperHeight / 2 - bodyWidth / 2, _stormtrooperWidth - _stormtrooperWidth / 8, bodyWidth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ namespace ProjectStormtrooper
|
||||
/// <summary>
|
||||
/// Шаг перемещения
|
||||
/// </summary>
|
||||
public double Step => (double)Speed * 500 / Weight;
|
||||
public double Step => (double)Speed * 250 / Weight;
|
||||
/// <summary>
|
||||
/// Инициализация полей объекта-класса штурмовика
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user