diff --git a/MotorBoat/MotorBoat/DrawningMotorBoat.cs b/MotorBoat/MotorBoat/DrawningMotorBoat.cs
index 1354686..dc38f74 100644
--- a/MotorBoat/MotorBoat/DrawningMotorBoat.cs
+++ b/MotorBoat/MotorBoat/DrawningMotorBoat.cs
@@ -19,32 +19,32 @@ namespace MotorBoat
///
/// Ширина окна
///
- private int _pictureWight;
+ private int _pictureWight = 800;
///
/// Высота окна
///
- private int _pictureHeight;
+ private int _pictureHeight = 450;
///
/// Левая координата прорисовки катера
///
- private int _startPosX;
+ private int _startPosX = 0;
///
/// Правая координата прорисовки катера
///
- private int _startPosY;
+ private int _startPosY = 0;
///
/// Ширина прорисовки автомобиля
///
- private readonly int _boatWight = 110;
+ private readonly int _boatWight = 120;
///
/// Высота прорисовки автомобиля
///
- private readonly int _boatHeight = 60;
+ private readonly int _boatHeight = 80;
///
/// Инициализация свойств
@@ -56,10 +56,10 @@ namespace MotorBoat
/// Ширина картинки
/// Выслота картинки
/// true - объект создан, false - проверка не пройдена, нельзя создать объект в этих размерах
- public bool Init(int speed, double weight, Color bodyColor, Color AdditionalColor,
- int width, int height)
+ public bool Init(int speed, double weight, Color bodyColor, Color AdditionalColor, int width, int height)
{
- // ПРИДУМАТЬ ПРОВЕРКИ
+ if (width <= _boatWight || height <= _boatHeight)
+ return false;
_pictureWight = width;
_pictureHeight = height;
EntityMotorBoat = new EntityMotorBoat();
@@ -74,9 +74,90 @@ namespace MotorBoat
/// Координата Y
public void SetPosition(int x, int y)
{
- // ИЗМЕНЕНИЕ X Y
+ if (EntityMotorBoat == null) return;
+ while (x + _boatWight > _pictureWight)
+ {
+ x -= (int)EntityMotorBoat.Step;
+ }
+ while (x < 0)
+ {
+ x += (int)EntityMotorBoat.Step;
+ }
+ while (y + _boatHeight > _pictureHeight)
+ {
+ y -= (int)EntityMotorBoat.Step;
+ }
+ while (y < 0)
+ {
+ y += (int)EntityMotorBoat.Step;
+ }
_startPosX = x;
_startPosY = y;
}
+
+ ///
+ /// Изменение направления перемещения
+ ///
+ /// Направление
+ public void MoveTransport(DirectionType direction)
+ {
+ if (EntityMotorBoat == null)
+ return;
+
+ switch (direction)
+ {
+ //влево
+ case DirectionType.Left:
+ if (_startPosX - EntityMotorBoat.Step > 0)
+ {
+ _startPosX -= (int)EntityMotorBoat.Step;
+ }
+ break;
+
+ //вверх
+ case DirectionType.Up:
+ if (_startPosY - EntityMotorBoat.Step > 0)
+ {
+ _startPosY -= (int)EntityMotorBoat.Step;
+ }
+ break;
+
+ //вправо
+ case DirectionType.Right:
+ if (_startPosX + _boatWight + EntityMotorBoat.Step < _pictureWight)
+ {
+ _startPosX += (int)EntityMotorBoat.Step;
+ }
+ break;
+
+ //вниз
+ case DirectionType.Down:
+ if (_startPosY + _pictureHeight + EntityMotorBoat.Step < _pictureHeight)
+ {
+ _startPosY += (int)EntityMotorBoat.Step;
+ }
+ break;
+ }
+ }
+
+ ///
+ /// Прорисовка объекта
+ ///
+ ///
+ public void DrawTransport(Graphics g)
+ {
+ if (EntityMotorBoat == null)
+ {
+ return;
+ }
+ Pen pen = new(Color.Black);
+ Brush additionalBrush = new SolidBrush(EntityMotorBoat.AdditionalColor);
+
+ // границы катера
+ g.DrawPolygon(pen, );
+
+ // штука овальная (палуба?)
+ g.DrawEllipse(pen, _startPosX + 2, _startPosY + 2, 18, 20);
+ }
}
}