Zhimolostnova A.V. Lab work 2 #2

Merged
eegov merged 5 commits from LabRab_2 into LabRab_1 2022-09-30 11:03:14 +04:00
4 changed files with 5 additions and 7 deletions
Showing only changes of commit cd528db9c6 - Show all commits

View File

@ -11,6 +11,6 @@ namespace Warship
Up=1,
Down=2,
Left=3,
Right=4
Right=4,
}
}

View File

@ -16,10 +16,9 @@ namespace Warship
private readonly int _warshipWidth = 120;
private readonly int _warshipHeight = 40;
public void Init(int speed, float weight,Color bodyColor)
public DrawingWarship(int speed, float weight,Color bodyColor)
{
Warship = new EntityWarship();
Warship.Init(speed, weight, bodyColor);
Warship = new EntityWarship(speed, weight, bodyColor);
}
public void SetPosition(int x, int y, int width, int height)

View File

@ -13,7 +13,7 @@ namespace Warship
public Color BodyColor { get; private set; }
public int Step => (int)(Speed * 2000 / Weight);
public void Init(int speed, float weight, Color bodyColor)
public EntityWarship(int speed, float weight, Color bodyColor)
{
Random rnd = new();
Speed = speed <= 0 ? rnd.Next(10, 60) : speed;

View File

@ -18,8 +18,7 @@ namespace Warship
private void buttonCreate_Click(object sender, EventArgs e)
{
Random rnd = new();
_warship = new DrawingWarship();
_warship.Init(rnd.Next(10, 60), rnd.Next(20000, 25000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
_warship = new DrawingWarship(rnd.Next(10, 60), rnd.Next(20000, 25000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
_warship.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxWarship.Width, pictureBoxWarship.Height);
toolStripStatusLabelSpeed.Text = $"Cêîðîñòü: {_warship.Warship.Speed}";
toolStripStatusLabelWeight.Text = $"Âåñ: {_warship.Warship.Weight}";