Init -> конструкторы
This commit is contained in:
parent
471ece01d3
commit
2737314d41
@ -22,8 +22,7 @@ namespace Traktor
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new Random();
|
||||
_Traktor = new TraktorDraw();
|
||||
_Traktor.Init(random.Next(100, 200), random.Next(2500, 5000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
|
||||
_Traktor = new TraktorDraw(random.Next(100, 200), random.Next(2500, 5000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
|
||||
_Traktor.SetPosition(random.Next(10, 50), random.Next(10, 50), pictureBoxTraktor.Width, pictureBoxTraktor.Height);
|
||||
toolStripStatusLabelSpeed.Text = $"Ñêîðîñòü: {_Traktor.Traktor.Speed}";
|
||||
toolStripStatusLabelWeight.Text = $"Âåñ: {_Traktor.Traktor.Weight}";
|
||||
|
@ -20,7 +20,7 @@ namespace Traktor
|
||||
//Шаг перемещения трактора
|
||||
public float Step => Speed * 100 / Weight;
|
||||
|
||||
public void Init(int speed, float weight, Color bodycolor)
|
||||
public EntityTraktor(int speed, float weight, Color bodycolor)
|
||||
{
|
||||
Random rnd = new Random();
|
||||
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
|
||||
|
@ -26,10 +26,9 @@ namespace Traktor
|
||||
/// Высота отрисовки сущности
|
||||
private readonly int entHeight = 100;
|
||||
|
||||
public void Init(int speed, float weight, Color bodycolor)
|
||||
public TraktorDraw(int speed, float weight, Color bodycolor)
|
||||
{
|
||||
Traktor = new EntityTraktor();
|
||||
Traktor.Init(speed, weight, bodycolor);
|
||||
Traktor = new EntityTraktor(speed, weight, bodycolor);
|
||||
}
|
||||
|
||||
//Установка позиции сущности
|
||||
|
Loading…
x
Reference in New Issue
Block a user