diff --git a/ProjectMotorBoat/ProjectMotorBoat/DrawingMotorBoat.cs b/ProjectMotorBoat/ProjectMotorBoat/DrawingMotorBoat.cs index 7e04a88..5f3e88c 100644 --- a/ProjectMotorBoat/ProjectMotorBoat/DrawingMotorBoat.cs +++ b/ProjectMotorBoat/ProjectMotorBoat/DrawingMotorBoat.cs @@ -74,25 +74,23 @@ public class DrawingMotorBoat { // TODO проверка, что объект "влезает" в размеры поля // если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена ✔ - if (_drawningBoatWidth < width) + if (_drawningBoatWidth < width && _drawningBoatHeight < height) { _pictureWidth = width; - if (_startPosX + _drawningBoatWidth > _pictureWidth) + _pictureHeight = height; + + if (_startPosX != null && _startPosX + _drawningBoatWidth > _pictureWidth) { _startPosX = _pictureWidth - _drawningBoatWidth; } - } - - if (_drawningBoatHeight < height) - { - _pictureHeight = height; - if (_startPosY + _drawningBoatHeight > _pictureHeight) + if (_startPosY != null && _startPosY + _drawningBoatHeight > _pictureHeight) { _startPosY = _pictureHeight - _drawningBoatHeight; } - } - return true; + return true; + } + return false; } /// @@ -118,6 +116,9 @@ public class DrawingMotorBoat y = (int)_pictureHeight - _drawningBoatHeight; } + if (x < 0) x = 0; + if (y < 0) y = 0; + _startPosX = x; _startPosY = y; }