ISEbd-22 Alimova M.S. Lab Work 02 #2

Closed
malimova wants to merge 21 commits from Lab2 into Lab1
Showing only changes of commit c11d4126a5 - Show all commits

View File

@ -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,
};
}