Добавление движения по диагонали в логику.

This commit is contained in:
1yuee 2022-09-13 17:06:36 +04:00
parent 231751cad6
commit b2870dd48f

View File

@ -20,8 +20,8 @@ namespace AirFighter
private int? _pictureWidth = null;
private int? _pictureHeight = null;
protected readonly int _aircraftWidth = 124;
protected readonly int _aircraftHeight = 70;
protected readonly int _aircraftWidth = 100;
protected readonly int _aircraftHeight = 100;
public void Init(int speed, float weight, Color bodyColor)
{
@ -87,6 +87,43 @@ namespace AirFighter
}
}
break;
case Direction.UpRight:
{
if (_startPosY - Plane.Step > 0 && _startPosX + _aircraftWidth + Plane.Step < _pictureWidth)
{
_startPosY -= Plane.Step;
_startPosX += Plane.Step;
}
}
break;
case Direction.UpLeft:
{
if (_startPosY - Plane.Step > 0 && _startPosX - Plane.Step > 0)
{
_startPosX -= Plane.Step;
_startPosY -= Plane.Step;
}
}
break;
case Direction.DownRight:
{
if (_startPosY + _aircraftHeight + Plane.Step < _pictureHeight && _startPosX + _aircraftWidth + Plane.Step < _pictureWidth)
{
_startPosY += Plane.Step;
_startPosX += Plane.Step;
}
}
break;
case Direction.DownLeft:
{
if (_startPosY + _aircraftHeight + Plane.Step < _pictureHeight && _startPosX - Plane.Step > 0)
{
_startPosY += Plane.Step;
_startPosX -= Plane.Step;
}
}
break;
}
}
@ -175,9 +212,6 @@ namespace AirFighter
}
public void ChangeBorders(int width, int height)