исправл
This commit is contained in:
commit
d6b298a36c
29
ProjectBulldozer/ProjectBulldozer/DirectionType1.cs
Normal file
29
ProjectBulldozer/ProjectBulldozer/DirectionType1.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectBulldozer;
|
||||||
|
|
||||||
|
public enum DirectionType1
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Вверх
|
||||||
|
/// </summary>
|
||||||
|
Up = 1,
|
||||||
|
/// <summary>
|
||||||
|
/// Вниз
|
||||||
|
/// </summary>
|
||||||
|
Down = 2,
|
||||||
|
/// <summary>
|
||||||
|
/// Влево
|
||||||
|
/// </summary>
|
||||||
|
Left = 3,
|
||||||
|
/// <summary>
|
||||||
|
/// Вправо
|
||||||
|
/// </summary>
|
||||||
|
Right = 4
|
||||||
|
|
||||||
|
}
|
||||||
|
//сделано
|
@ -26,9 +26,9 @@ public class DrawningBulldozer
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private int? _startPosY;
|
private int? _startPosY;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ширина прорисовки автомобиля
|
/// Ширина прорисовки автомобиля
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly int _BulldozerWidth = 180;
|
private readonly int _BulldozerWidth = 180;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Высота прорисовки автомобиля
|
/// Высота прорисовки автомобиля
|
||||||
@ -48,7 +48,7 @@ public class DrawningBulldozer
|
|||||||
additionalColor, bool additionalOtval, bool additionalRihl)
|
additionalColor, bool additionalOtval, bool additionalRihl)
|
||||||
{
|
{
|
||||||
EntityBulldozer = new EntityBulldozer();
|
EntityBulldozer = new EntityBulldozer();
|
||||||
EntityBulldozer.Init(speed, weight, bodyColor, additionalColor, additionalOtval,
|
EntityBulldozer.Init(speed, weight, bodyColor, additionalColor, additionalOtval,
|
||||||
additionalRihl);
|
additionalRihl);
|
||||||
|
|
||||||
_pictureWidth = null;
|
_pictureWidth = null;
|
||||||
@ -67,15 +67,15 @@ public class DrawningBulldozer
|
|||||||
{
|
{
|
||||||
if (_BulldozerWidth < width && _BulldozerHeight < height)
|
if (_BulldozerWidth < width && _BulldozerHeight < height)
|
||||||
{
|
{
|
||||||
_pictureWidth = width;
|
_pictureWidth = width;
|
||||||
_pictureHeight = height;
|
_pictureHeight = height;
|
||||||
if (_startPosX.HasValue && _startPosY.HasValue)
|
if (_startPosX.HasValue && _startPosY.HasValue)
|
||||||
{
|
{
|
||||||
SetPosition(_startPosX.Value, _startPosY.Value);
|
SetPosition(_startPosX.Value, _startPosY.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -96,9 +96,9 @@ public class DrawningBulldozer
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_startPosX = x;
|
_startPosX = x;
|
||||||
_startPosY = y;
|
_startPosY = y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Изменение направления перемещения
|
/// Изменение направления перемещения
|
||||||
|
@ -47,7 +47,7 @@ namespace ProjectBulldozer
|
|||||||
{
|
{
|
||||||
Random random = new();
|
Random random = new();
|
||||||
_drawningBulldozer = new DrawningBulldozer();
|
_drawningBulldozer = new DrawningBulldozer();
|
||||||
|
|
||||||
_drawningBulldozer.Init(random.Next(100, 300), random.Next(1000, 3000),
|
_drawningBulldozer.Init(random.Next(100, 300), random.Next(1000, 3000),
|
||||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
||||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
||||||
@ -56,12 +56,12 @@ namespace ProjectBulldozer
|
|||||||
_drawningBulldozer.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
_drawningBulldozer.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Перемещение объекта по форме (нажатие кнопок навигации)
|
/// Перемещение объекта по форме (нажатие кнопок навигации)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
private void ButtonMove_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_drawningBulldozer == null)
|
if (_drawningBulldozer == null)
|
||||||
{
|
{
|
||||||
@ -73,19 +73,19 @@ namespace ProjectBulldozer
|
|||||||
{
|
{
|
||||||
case "buttonUp":
|
case "buttonUp":
|
||||||
result =
|
result =
|
||||||
_drawningBulldozer.MoveTransport(DirectionType1.Up);
|
_drawningBulldozer.MoveTransport(DirectionType.Up);
|
||||||
break;
|
break;
|
||||||
case "buttonDown":
|
case "buttonDown":
|
||||||
result =
|
result =
|
||||||
_drawningBulldozer.MoveTransport(DirectionType1.Down);
|
_drawningBulldozer.MoveTransport(DirectionType.Down);
|
||||||
break;
|
break;
|
||||||
case "buttonLeft":
|
case "buttonLeft":
|
||||||
result =
|
result =
|
||||||
_drawningBulldozer.MoveTransport(DirectionType1.Left);
|
_drawningBulldozer.MoveTransport(DirectionType.Left);
|
||||||
break;
|
break;
|
||||||
case "buttonRight":
|
case "buttonRight":
|
||||||
result =
|
result =
|
||||||
_drawningBulldozer.MoveTransport(DirectionType1.Right);
|
_drawningBulldozer.MoveTransport(DirectionType.Right);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (result)
|
if (result)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user