diff --git a/Hydroplane/DrawingHydroplane.cs b/Hydroplane/DrawingHydroplane.cs
index f4fcf43..419881c 100644
--- a/Hydroplane/DrawingHydroplane.cs
+++ b/Hydroplane/DrawingHydroplane.cs
@@ -11,7 +11,7 @@ namespace Hydroplane
///
/// Класс-сущность
///
- public EntityHydroplane? EntitySportCar { get; private set; }
+ public EntityHydroplane? EntityHydroplane { get; private set; }
///
/// Ширина окна
///
@@ -31,11 +31,11 @@ namespace Hydroplane
///
/// Ширина прорисовки автомобиля
///
- private readonly int _carWidth = 110;
+ private readonly int _planeWidth = 175;
///
/// Высота прорисовки автомобиля
///
- private readonly int _carHeight = 60;
+ private readonly int _planeHeight = 100;
///
/// Инициализация свойств
///
@@ -43,23 +43,23 @@ namespace Hydroplane
/// Вес
/// Цвет кузова
/// Дополнительный цвет
- /// Признак наличия обвеса
- /// Признак наличия антикрыла
- /// Признак наличия гоночной полосы
+ /// Признак наличия обвеса
+ /// Признак наличия антикрыла
/// Ширина картинки
/// Высота картинки
/// true - объект создан, false - проверка не пройдена, нельзя создать объект в этих размерах
-public bool Init(int speed, double weight, Color bodyColor, Color
-additionalColor, bool bodyKit, bool wing, bool sportLine, int width, int height)
+ public bool Init(int speed, double weight, Color bodyColor, Color
+ additionalColor, bool boat, bool bobber, int width, int height)
{
// TODO: Продумать проверки
_pictureWidth = width;
_pictureHeight = height;
- EntitySportCar = new EntityHydroplane();
- EntitySportCar.Init(speed, weight, bodyColor, additionalColor,
- bodyKit, wing, sportLine);
+ EntityHydroplane = new EntityHydroplane();
+ EntityHydroplane.Init(speed, weight, bodyColor, additionalColor,
+ boat, bobber);
return true;
}
+
///
/// Установка позиции
///
@@ -71,13 +71,14 @@ additionalColor, bool bodyKit, bool wing, bool sportLine, int width, int height)
_startPosX = x;
_startPosY = y;
}
+
///
/// Изменение направления перемещения
///
/// Направление
public void MoveTransport(DirectionType direction)
{
- if (EntitySportCar == null)
+ if (EntityHydroplane == null)
{
return;
}
@@ -85,49 +86,51 @@ additionalColor, bool bodyKit, bool wing, bool sportLine, int width, int height)
{
//влево
case DirectionType.Left:
- if (_startPosX - EntitySportCar.Step > 0)
+ if (_startPosX - EntityHydroplane.Step > 0)
{
- _startPosX -= (int)EntitySportCar.Step;
+ _startPosX -= (int)EntityHydroplane.Step;
}
break;
//вверх
case DirectionType.Up:
- if (_startPosY - EntitySportCar.Step > 0)
+ if (_startPosY - EntityHydroplane.Step > 0)
{
- _startPosY -= (int)EntitySportCar.Step;
+ _startPosY -= (int)EntityHydroplane.Step;
}
break;
// вправо
case DirectionType.Right:
- if (_startPosX + EntitySportCar.Step + _carWidth < _pictureWidth)
+ if (_startPosX + EntityHydroplane.Step + _planeWidth < _pictureWidth)
{
- _startPosX += (int)EntitySportCar.Step;
+ _startPosX += (int)EntityHydroplane.Step;
}
break;
//вниз
case DirectionType.Down:
- if (_startPosY + EntitySportCar.Step + _carHeight < _pictureHeight)
+ if (_startPosY + EntityHydroplane.Step + _planeHeight < _pictureHeight)
{
- _startPosY += (int)EntitySportCar.Step;
+ _startPosY += (int)EntityHydroplane.Step;
}
break;
}
}
+
///
/// Прорисовка объекта
///
///
public void DrawTransport(Graphics g)
{
- if (EntitySportCar == null)
+ if (EntityHydroplane == null)
{
return;
}
Pen pen = new(Color.Black);
Brush additionalBrush = new
- SolidBrush(EntitySportCar.AdditionalColor);
+ SolidBrush(EntityHydroplane.AdditionalColor);
+ /*
// обвесы
- if (EntitySportCar.BodyKit)
+ if (EntityHydroplane.BodyKit)
{
g.DrawEllipse(pen, _startPosX + 90, _startPosY, 20, 20);
g.DrawEllipse(pen, _startPosX + 90, _startPosY + 40, 20,
@@ -196,7 +199,7 @@ _startPosY + 1, 15, 15);
g.FillEllipse(brYellow, _startPosX + 80, _startPosY + 35, 20,
20);
//кузов
- Brush br = new SolidBrush(EntitySportCar.BodyColor);
+ Brush br = new SolidBrush(EntityHydroplane.BodyColor);
g.FillRectangle(br, _startPosX + 10, _startPosY + 15, 10, 30);
g.FillRectangle(br, _startPosX + 90, _startPosY + 15, 10, 30);
g.FillRectangle(br, _startPosX + 20, _startPosY + 5, 70, 50);
@@ -218,7 +221,7 @@ _startPosY + 1, 15, 15);
g.DrawRectangle(pen, _startPosX + 10, _startPosY + 15, 15,
30);
// спортивная линия
- if (EntitySportCar.SportLine)
+ if (EntityHydroplane.SportLine)
{
g.FillRectangle(additionalBrush, _startPosX + 75,
_startPosY + 23, 25, 15);
@@ -228,13 +231,58 @@ _startPosY + 1, 15, 15);
_startPosY + 23, 20, 15);
}
// крыло
- if (EntitySportCar.Wing)
+ if (EntityHydroplane.Wing)
{
g.FillRectangle(additionalBrush, _startPosX, _startPosY
+ 5, 10, 50);
g.DrawRectangle(pen, _startPosX, _startPosY + 5, 10,
50);
}
+ */
+ //основа
+ g.DrawRectangle(pen, _startPosX + 5, _startPosY + 25, 125, 30);
+
+ //хвост
+ g.DrawLine(pen, _startPosX + 5, _startPosY + 25, _startPosX + 5, _startPosY);
+ g.DrawLine(pen, _startPosX + 55, _startPosY + 25, _startPosX + 5, _startPosY);
+
+ //нос
+ g.DrawLine(pen, _startPosX + 130, _startPosY + 25, _startPosX + 160, _startPosY + 40);
+ g.DrawLine(pen, _startPosX + 130, _startPosY + 55, _startPosX + 160, _startPosY + 40);
+ g.DrawLine(pen, _startPosX + 130, _startPosY + 40, _startPosX + 160, _startPosY + 40);
+
+ //иллюминаторы
+ g.DrawEllipse(pen, _startPosX + 40, _startPosY + 30, 10, 10);
+ g.DrawEllipse(pen, _startPosX + 60, _startPosY + 30, 10, 10);
+ g.DrawEllipse(pen, _startPosX + 80, _startPosY + 30, 10, 10);
+
+ //крыло сбоку
+ g.DrawEllipse(pen, _startPosX + 35, _startPosY + 43, 80, 7);
+
+ //ножки снизу
+ g.DrawLine(pen, _startPosX + 65, _startPosY + 55, _startPosX + 65, _startPosY + 70);
+ g.DrawLine(pen, _startPosX + 70, _startPosY + 55, _startPosX + 70, _startPosY + 70);
+ g.DrawLine(pen, _startPosX + 125, _startPosY + 55, _startPosX + 125, _startPosY + 70);
+ g.DrawLine(pen, _startPosX + 130, _startPosY + 55, _startPosX + 130, _startPosY + 70);
+
+ //лодка или колеса
+ if (EntityHydroplane.Boat)
+ {
+ g.DrawRectangle(pen, _startPosX + 55, _startPosY + 70, 100, 10);
+ g.DrawLine(pen, _startPosX + 155, _startPosY + 70, _startPosX + 175, _startPosY + 70);
+ g.DrawLine(pen, _startPosX + 175, _startPosY + 70, _startPosX + 155, _startPosY + 80);
+ }
+ else
+ {
+ g.DrawEllipse(pen, _startPosX + 60, _startPosY + 70, 15, 15);
+ g.DrawEllipse(pen, _startPosX + 120, _startPosY + 70, 15, 15);
+ }
+
+ //поплавок
+ if (EntityHydroplane.Bobber)
+ {
+ g.DrawEllipse(pen, _startPosX, _startPosY + 21, 32, 8);
+ }
}
}
}
diff --git a/Hydroplane/EntityHydroplane.cs b/Hydroplane/EntityHydroplane.cs
index 113d95b..2f0dcb4 100644
--- a/Hydroplane/EntityHydroplane.cs
+++ b/Hydroplane/EntityHydroplane.cs
@@ -25,17 +25,13 @@ namespace Hydroplane
///
public Color AdditionalColor { get; private set; }
///
- /// Признак (опция) наличия обвеса
+ /// Признак (опция) наличия надувной лодки
///
- public bool BodyKit { get; private set; }
+ public bool Boat { get; private set; }
///
- /// Признак (опция) наличия антикрыла
+ /// Признак (опция) наличия поплавка
///
- public bool Wing { get; private set; }
- ///
- /// Признак (опция) наличия гоночной полосы
- ///
- public bool SportLine { get; private set; }
+ public bool Bobber { get; private set; }
///
/// Шаг перемещения автомобиля
///
@@ -47,19 +43,17 @@ namespace Hydroplane
/// Вес автомобиля
/// Основной цвет
/// Дополнительный цвет
- /// Признак наличия обвеса
- /// Признак наличия антикрыла
- /// Признак наличия гоночной полосы
+ /// Признак наличия обвеса
+ /// Признак наличия антикрыла
public void Init(int speed, double weight, Color bodyColor, Color
- additionalColor, bool bodyKit, bool wing, bool sportLine)
+ additionalColor, bool boat, bool bobber)
{
Speed = speed;
Weight = weight;
BodyColor = bodyColor;
AdditionalColor = additionalColor;
- BodyKit = bodyKit;
- Wing = wing;
- SportLine = sportLine;
+ Boat = boat;
+ Bobber = bobber;
}
}
}
diff --git a/Hydroplane/Form1.cs b/Hydroplane/Form1.cs
index 412b24f..0e33b65 100644
--- a/Hydroplane/Form1.cs
+++ b/Hydroplane/Form1.cs
@@ -5,7 +5,7 @@ namespace Hydroplane
///
/// -
///
- private DrawningHydroplane? _drawningSportCar;
+ private DrawningHydroplane? _drawningHydroplane;
public Form1()
{
InitializeComponent();
@@ -16,14 +16,14 @@ namespace Hydroplane
///
private void Draw()
{
- if (_drawningSportCar == null)
+ if (_drawningHydroplane == null)
{
return;
}
Bitmap bmp = new(pictureBoxHydroplane.Width,
pictureBoxHydroplane.Height);
Graphics gr = Graphics.FromImage(bmp);
- _drawningSportCar.DrawTransport(gr);
+ _drawningHydroplane.DrawTransport(gr);
pictureBoxHydroplane.Image = bmp;
}
@@ -35,17 +35,16 @@ namespace Hydroplane
private void buttonCreate_Click(object sender, EventArgs e)
{
Random random = new();
- _drawningSportCar = new DrawningHydroplane();
- _drawningSportCar.Init(random.Next(100, 300),
+ _drawningHydroplane = new DrawningHydroplane();
+ _drawningHydroplane.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)),
pictureBoxHydroplane.Width, pictureBoxHydroplane.Height);
- _drawningSportCar.SetPosition(random.Next(10, 100),
+ _drawningHydroplane.SetPosition(random.Next(10, 100),
random.Next(10, 100));
Draw();
}
@@ -57,7 +56,7 @@ namespace Hydroplane
///
private void buttonMove_Click(object sender, EventArgs e)
{
- if (_drawningSportCar == null)
+ if (_drawningHydroplane == null)
{
return;
}
@@ -65,16 +64,16 @@ namespace Hydroplane
switch (name)
{
case "buttonUp":
- _drawningSportCar.MoveTransport(DirectionType.Up);
+ _drawningHydroplane.MoveTransport(DirectionType.Up);
break;
case "buttonDown":
- _drawningSportCar.MoveTransport(DirectionType.Down);
+ _drawningHydroplane.MoveTransport(DirectionType.Down);
break;
case "buttonLeft":
- _drawningSportCar.MoveTransport(DirectionType.Left);
+ _drawningHydroplane.MoveTransport(DirectionType.Left);
break;
case "buttonRight":
- _drawningSportCar.MoveTransport(DirectionType.Right);
+ _drawningHydroplane.MoveTransport(DirectionType.Right);
break;
}
Draw();