From c11d4126a5ac23c01299a17ebc4d03eba5f1b904 Mon Sep 17 00:00:00 2001 From: malimova Date: Sat, 7 Oct 2023 09:27:50 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B8?= =?UTF-8?q?=20=D0=B4=D0=B2=D0=B8=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/DrawningAirPlane.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/AirBomber/AirBomber/DrawningAirPlane.cs b/AirBomber/AirBomber/DrawningAirPlane.cs index 3d6d33a..daeaea6 100644 --- a/AirBomber/AirBomber/DrawningAirPlane.cs +++ b/AirBomber/AirBomber/DrawningAirPlane.cs @@ -81,6 +81,14 @@ namespace AirBomber public void SetPosition(int x, int y) { // TODO: Изменение x, y, если при установке объект выходит за границы + if (x < 0 || x + _airPlaneWidth > _pictureWidth) + { + x = _pictureWidth - _airPlaneWidth; + } + if (y < 0 || y + _airPlaneHeight > _pictureHeight) + { + y = _pictureHeight - _airPlaneHeight; + } _startPosX = x; _startPosY = y; } @@ -217,9 +225,9 @@ namespace AirBomber //вверх DirectionType.Up => _startPosY - EntityAirPlane.Step > 0, // вправо - DirectionType.Right => _startPosX + EntityAirPlane.Step < _pictureWidth, + DirectionType.Right => _startPosX + EntityAirPlane.Step + _airPlaneWidth < _pictureWidth, //вниз - DirectionType.Down => _startPosY + EntityAirPlane.Step < _pictureHeight, + DirectionType.Down => _startPosY + EntityAirPlane.Step + _airPlaneHeight< _pictureHeight, _ => false, }; }