Aleikin A.M. LabWork02 #2

Merged
eegov merged 9 commits from LabWork02 into LabWork01 2022-10-28 09:12:52 +04:00
3 changed files with 5 additions and 7 deletions
Showing only changes of commit 746f60a4b1 - Show all commits

View File

@ -16,10 +16,9 @@ namespace AirBomber
private readonly int _airBomberWidth = 100;
private readonly int _airBomberHeight = 100;
public void Init(int speed, float weight, Color bodyColor)
public DrawningBomber(int speed, float weight, Color bodyColor)
{
AirBomber = new EntityAirBomber();
AirBomber.Init(speed, weight, bodyColor);
AirBomber = new EntityAirBomber(speed, weight, bodyColor);
}
public void SetPosition(int x, int y, int width, int height)

View File

@ -13,9 +13,9 @@ namespace AirBomber
public Color BodyColor { get; private set; }
public float Step => Speed * 100 / Weight;
public void Init(int speed, float weight, Color bodyColor)
public EntityAirBomber(int speed, float weight, Color bodyColor)
{
Random rnd = new();
Random rnd = new Random();
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
Weight = weight <= 0 ? rnd.Next(40, 70) : weight;
BodyColor = bodyColor;

View File

@ -19,8 +19,7 @@ namespace AirBomber
private void ButtonCreate_Click(object sender, EventArgs e)
{
Random rnd = new();
_airBomber = new DrawningBomber();
_airBomber.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
_airBomber = new DrawningBomber(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
_airBomber.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxAirBomber.Width, pictureBoxAirBomber.Height);
toolStripStatusLabelSpeed.Text = $"Ñêîðîñòü: {_airBomber.AirBomber.Speed}";
toolStripStatusLabelWeight.Text = $"Âåñ: {_airBomber.AirBomber.Weight}";