From cb303b9ca447426ed014b56c846221eee71707b4 Mon Sep 17 00:00:00 2001 From: dlopatin Date: Mon, 1 Apr 2024 14:09:38 +0300 Subject: [PATCH] hotfix SetPosition() --- WarmlyLocomotive/DrawningWarmlyLocomotive.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/WarmlyLocomotive/DrawningWarmlyLocomotive.cs b/WarmlyLocomotive/DrawningWarmlyLocomotive.cs index b5896ac..1fa431d 100644 --- a/WarmlyLocomotive/DrawningWarmlyLocomotive.cs +++ b/WarmlyLocomotive/DrawningWarmlyLocomotive.cs @@ -72,19 +72,29 @@ public class DrawningWarmlyLocomotive return; } + //проверка у if ((y + _drawningLocomotiveHeight) > _pictureHeight) { _startPosY = _pictureHeight - _drawningLocomotiveHeight; } + else if(y < 0) + { + _startPosY = 0; + } else { _startPosY = y; } - + + //проверка х if ((x + _drawningLocomotiveWidth) > _pictureWidth) { _startPosX = _pictureWidth - _drawningLocomotiveWidth; } + else if(x < 0) + { + _startPosX = 0; + } else { _startPosX = x;