Готовая 1 лаба

This commit is contained in:
platoff aeeee 2023-09-27 09:20:00 +04:00
parent 02c4fa2ec2
commit a7f1fc2910
2 changed files with 19 additions and 11 deletions

View File

@ -58,13 +58,16 @@ namespace Tank
additionalColor, bool bodyKit, bool trunk, bool sportLine, int width, int height) additionalColor, bool bodyKit, bool trunk, bool sportLine, int width, int height)
{ {
// TODO: Продумать проверки // TODO: Продумать проверки
if (width > _tankWidth && height > _tankHeight && speed > 0 && weight > 0)
_pictureWidth = width; {
_pictureHeight = height; _pictureWidth = width;
EntityTank = new EntityTank(); _pictureHeight = height;
EntityTank.Init(speed, weight, bodyColor, additionalColor, EntityTank = new EntityTank();
bodyKit, trunk, sportLine); EntityTank.Init(speed, weight, bodyColor, additionalColor,
return true; bodyKit, trunk, sportLine);
return true;
}
return false;
} }
/// <summary> /// <summary>
/// Установка позиции /// Установка позиции
@ -73,8 +76,13 @@ namespace Tank
/// <param name="y">Координата Y</param> /// <param name="y">Координата Y</param>
public void SetPosition(int x, int y) public void SetPosition(int x, int y)
{ {
_startPosX = x; // проверки
_startPosY = y; if (x >= 0 && x + _tankWidth <= _pictureWidth &&
y >= 0 && y + _tankHeight <= _pictureHeight)
{
_startPosX = x;
_startPosY = y;
}
} }
/// <summary> /// <summary>
/// Изменение направления перемещения /// Изменение направления перемещения

View File

@ -37,9 +37,9 @@ namespace Tank
/// </summary> /// </summary>
public bool SportLine { get; private set; } public bool SportLine { get; private set; }
/// <summary> /// <summary>
/// Шаг перемещения автомобиля /// Шаг перемещения танка
/// </summary> /// </summary>
public double Step => (double)Speed * 100 / Weight; public double Step => (double)Speed * 200 / Weight;
/// <summary> /// <summary>
/// Инициализация полей объекта-класса спортивного автомобиля /// Инициализация полей объекта-класса спортивного автомобиля
/// </summary> /// </summary>