From e8a24da5cd4e4b849a15a7afe6b75358ca64626a Mon Sep 17 00:00:00 2001 From: ujijrujijr Date: Thu, 19 Oct 2023 19:12:45 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=9B=D0=B0=D0=B11?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Trolleybus/Trolleybus/DrawingTrolleybus.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Trolleybus/Trolleybus/DrawingTrolleybus.cs b/Trolleybus/Trolleybus/DrawingTrolleybus.cs index 07de4ba..d8532d6 100644 --- a/Trolleybus/Trolleybus/DrawingTrolleybus.cs +++ b/Trolleybus/Trolleybus/DrawingTrolleybus.cs @@ -68,11 +68,8 @@ namespace Trolleybus /// Координата Y public void SetPosition(int x, int y) { - if (x > _pictureWidth || y > _pictureHeight) { - return; - } - _startPosX = x; - _startPosY = y; + _startPosX = Math.Min(Math.Max(x, 0), _pictureWidth - _trolleybusWidth); + _startPosY = Math.Min(Math.Max(y, 0), _pictureHeight - _trolleybusHeight); } /// /// Изменение направления перемещения