Первая лабораторная работа. Изменение ограничений на перемещение

This commit is contained in:
Алина Батылкина 2022-09-26 21:55:34 +04:00
parent a3414973c1
commit fb6cec9d63

View File

@ -19,12 +19,14 @@
} }
public void SetPosition(int x, int y, int width, int height) public void SetPosition(int x, int y, int width, int height)
{ {
// TODO checks if (x + _WarmlyShipWidth <= width && y + _WarmlyShipHeight <= height && x >= 0 && y >= 0)
{
_startPosX = x; _startPosX = x;
_startPosY = y; _startPosY = y;
_pictureWidth = width; _pictureWidth = width;
_pictureHeight = height; _pictureHeight = height;
} }
}
public void MoveTransport(Direction direction) public void MoveTransport(Direction direction)
{ {
if (!_pictureWidth.HasValue || !_pictureHeight.HasValue) if (!_pictureWidth.HasValue || !_pictureHeight.HasValue)
@ -35,7 +37,7 @@
{ {
// вправо // вправо
case Direction.Right: case Direction.Right:
if (_startPosX + _WarmlyShipWidth + WarmlyShip.Step < _pictureWidth) if (_startPosX + _WarmlyShipWidth + WarmlyShip.Step + 60 < _pictureWidth)
{ {
_startPosX += WarmlyShip.Step; _startPosX += WarmlyShip.Step;
} }
@ -56,7 +58,7 @@
break; break;
//вниз //вниз
case Direction.Down: case Direction.Down:
if (_startPosY + _WarmlyShipHeight + WarmlyShip.Step < _pictureHeight) if (_startPosY + _WarmlyShipHeight + WarmlyShip.Step + 40 < _pictureHeight)
{ {
_startPosY += WarmlyShip.Step; _startPosY += WarmlyShip.Step;
} }