commit
This commit is contained in:
parent
9df4243919
commit
2a10ccebd0
@ -19,32 +19,32 @@ namespace MotorBoat
|
||||
/// <summary>
|
||||
/// Ширина окна
|
||||
/// </summary>
|
||||
private int _pictureWight;
|
||||
private int _pictureWight = 800;
|
||||
|
||||
/// <summary>
|
||||
/// Высота окна
|
||||
/// </summary>
|
||||
private int _pictureHeight;
|
||||
private int _pictureHeight = 450;
|
||||
|
||||
/// <summary>
|
||||
/// Левая координата прорисовки катера
|
||||
/// </summary>
|
||||
private int _startPosX;
|
||||
private int _startPosX = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Правая координата прорисовки катера
|
||||
/// </summary>
|
||||
private int _startPosY;
|
||||
private int _startPosY = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Ширина прорисовки автомобиля
|
||||
/// </summary>
|
||||
private readonly int _boatWight = 110;
|
||||
private readonly int _boatWight = 120;
|
||||
|
||||
/// <summary>
|
||||
/// Высота прорисовки автомобиля
|
||||
/// </summary>
|
||||
private readonly int _boatHeight = 60;
|
||||
private readonly int _boatHeight = 80;
|
||||
|
||||
/// <summary>
|
||||
/// Инициализация свойств
|
||||
@ -56,10 +56,10 @@ namespace MotorBoat
|
||||
/// <param name="wight">Ширина картинки</param>
|
||||
/// <param name="height">Выслота картинки</param>
|
||||
/// <returns>true - объект создан, false - проверка не пройдена, нельзя создать объект в этих размерах</returns>
|
||||
public bool Init(int speed, double weight, Color bodyColor, Color AdditionalColor,
|
||||
int width, int height)
|
||||
public bool Init(int speed, double weight, Color bodyColor, Color AdditionalColor, int width, int height)
|
||||
{
|
||||
// ПРИДУМАТЬ ПРОВЕРКИ
|
||||
if (width <= _boatWight || height <= _boatHeight)
|
||||
return false;
|
||||
_pictureWight = width;
|
||||
_pictureHeight = height;
|
||||
EntityMotorBoat = new EntityMotorBoat();
|
||||
@ -74,9 +74,90 @@ namespace MotorBoat
|
||||
/// <param name="y">Координата Y</param>
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
// ИЗМЕНЕНИЕ X Y
|
||||
if (EntityMotorBoat == null) return;
|
||||
while (x + _boatWight > _pictureWight)
|
||||
{
|
||||
x -= (int)EntityMotorBoat.Step;
|
||||
}
|
||||
while (x < 0)
|
||||
{
|
||||
x += (int)EntityMotorBoat.Step;
|
||||
}
|
||||
while (y + _boatHeight > _pictureHeight)
|
||||
{
|
||||
y -= (int)EntityMotorBoat.Step;
|
||||
}
|
||||
while (y < 0)
|
||||
{
|
||||
y += (int)EntityMotorBoat.Step;
|
||||
}
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Изменение направления перемещения
|
||||
/// </summary>
|
||||
/// <param name="direction">Направление</param>
|
||||
public void MoveTransport(DirectionType direction)
|
||||
{
|
||||
if (EntityMotorBoat == null)
|
||||
return;
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
//влево
|
||||
case DirectionType.Left:
|
||||
if (_startPosX - EntityMotorBoat.Step > 0)
|
||||
{
|
||||
_startPosX -= (int)EntityMotorBoat.Step;
|
||||
}
|
||||
break;
|
||||
|
||||
//вверх
|
||||
case DirectionType.Up:
|
||||
if (_startPosY - EntityMotorBoat.Step > 0)
|
||||
{
|
||||
_startPosY -= (int)EntityMotorBoat.Step;
|
||||
}
|
||||
break;
|
||||
|
||||
//вправо
|
||||
case DirectionType.Right:
|
||||
if (_startPosX + _boatWight + EntityMotorBoat.Step < _pictureWight)
|
||||
{
|
||||
_startPosX += (int)EntityMotorBoat.Step;
|
||||
}
|
||||
break;
|
||||
|
||||
//вниз
|
||||
case DirectionType.Down:
|
||||
if (_startPosY + _pictureHeight + EntityMotorBoat.Step < _pictureHeight)
|
||||
{
|
||||
_startPosY += (int)EntityMotorBoat.Step;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Прорисовка объекта
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
public void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityMotorBoat == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Pen pen = new(Color.Black);
|
||||
Brush additionalBrush = new SolidBrush(EntityMotorBoat.AdditionalColor);
|
||||
|
||||
// границы катера
|
||||
g.DrawPolygon(pen, );
|
||||
|
||||
// штука овальная (палуба?)
|
||||
g.DrawEllipse(pen, _startPosX + 2, _startPosY + 2, 18, 20);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user