Лабораторная_2 #3
@ -70,28 +70,28 @@ namespace ProjectMachine
|
||||
case Direction.Left:
|
||||
for (int i = GetCoord().TopCoord; i <= GetCoord().BottomCoord; i++)
|
||||
{
|
||||
if (_map[GetCoord().LeftCoord - 1, i] == _barrier)
|
||||
if (_map[GetCoord().LeftCoord - (int)((_drawningObject.Step) / _size_x) - 1, i] == _barrier)
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case Direction.Right:
|
||||
for (int i = GetCoord().TopCoord; i < GetCoord().BottomCoord; i++)
|
||||
{
|
||||
if (_map[GetCoord().RightCoord + 1, i] == _barrier)
|
||||
if (_map[GetCoord().RightCoord + (int)((_drawningObject.Step) / _size_x) + 1, i] == _barrier)
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case Direction.Up:
|
||||
for (int i = GetCoord().LeftCoord; i < GetCoord().RightCoord; i++)
|
||||
{
|
||||
if (_map[i, GetCoord().TopCoord - 1] == _barrier)
|
||||
if (_map[i, GetCoord().TopCoord - (int)((_drawningObject.Step) / _size_y) - 1] == _barrier)
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case Direction.Down:
|
||||
for (int i = GetCoord().LeftCoord; i < GetCoord().RightCoord; i++)
|
||||
{
|
||||
if (_map[i, GetCoord().BottomCoord + 1] == _barrier)
|
||||
if (_map[i, GetCoord().BottomCoord + (int)((_drawningObject.Step) / _size_y) + 1] == _barrier)
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
@ -15,7 +15,6 @@ namespace ProjectMachine
|
||||
/// <param name="weight">Вес автомобиля</param>
|
||||
/// <param name="bodyColor">Цвет кузова</param>
|
||||
/// <param name="dopColor">Дополнительный цвет</param>
|
||||
/// <param name="bodyKit">Признак наличия обвеса</param>
|
||||
/// <param name="turret">Признак наличия башни с орудием</param>
|
||||
/// <param name="gun">Признак наличия зенитного пулемета</param>
|
||||
public DrawningTank(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool turret, bool gun) :
|
||||
@ -33,15 +32,16 @@ namespace ProjectMachine
|
||||
Pen pen = new(Color.Black);
|
||||
Brush dopBrush = new SolidBrush(tank.DopColor);
|
||||
|
||||
if (tank.BodyKit)
|
||||
if (tank.Turret)
|
||||
{
|
||||
g.FillRectangle(dopBrush, _startPosX + 45, _startPosY, 20, 10);
|
||||
g.DrawLine(pen, _startPosX + 65, _startPosY + 2, _startPosX + 85, _startPosY + 2);
|
||||
}
|
||||
|
||||
if (tank.Turret)
|
||||
if (tank.Gun)
|
||||
{
|
||||
g.FillRectangle(dopBrush, _startPosX + 45, _startPosY, 20, 10);
|
||||
g.FillRectangle(dopBrush, _startPosX + 23, _startPosY + 4, 3, 11);
|
||||
g.DrawLine(pen, _startPosX + 23, _startPosY + 8, _startPosX + 5, _startPosY + 8);
|
||||
}
|
||||
|
||||
_startPosX += 10;
|
||||
|
@ -39,7 +39,7 @@ namespace ProjectMachine
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
var machine = new DrawningMachine(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||
var machine = new DrawningMachine(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||
SetData(machine);
|
||||
}
|
||||
/// <summary>
|
||||
|
Loading…
Reference in New Issue
Block a user