Третий коммит. 70%
This commit is contained in:
parent
1dcad5809b
commit
5db329405b
@ -101,6 +101,7 @@
|
||||
this.buttonDown.TabIndex = 3;
|
||||
this.buttonDown.Text = " ";
|
||||
this.buttonDown.UseVisualStyleBackColor = true;
|
||||
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
@ -112,6 +113,7 @@
|
||||
this.buttonUp.TabIndex = 4;
|
||||
this.buttonUp.Text = " ";
|
||||
this.buttonUp.UseVisualStyleBackColor = true;
|
||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
@ -123,6 +125,7 @@
|
||||
this.buttonLeft.TabIndex = 5;
|
||||
this.buttonLeft.Text = " ";
|
||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
@ -134,6 +137,7 @@
|
||||
this.buttonRight.TabIndex = 6;
|
||||
this.buttonRight.Text = " ";
|
||||
this.buttonRight.UseVisualStyleBackColor = true;
|
||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// FormWarship
|
||||
//
|
||||
|
@ -27,11 +27,32 @@ namespace AircraftCarrier
|
||||
Random rnd = new();
|
||||
_warship = new DrawingWarship();
|
||||
_warship.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), 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)
|
||||
_warship.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxWarship.Width, pictureBoxWarship.Height);
|
||||
toolStripStatusLabelSpeed.Text = $"Ñêîðîñòü: {_warship.Warship.Speed}";
|
||||
toolStripStatusLabelWeight.Text = $"Âåñ: {_warship.Warship.Weight}";
|
||||
toolStripStatusLabelBodyColor.Text = $"Öâåò: {_warship.Warship.BodyColor.Name}";
|
||||
Draw();
|
||||
}
|
||||
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
_warship?.MoveTransport(Direction.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
_warship?.MoveTransport(Direction.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
_warship?.MoveTransport(Direction.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
_warship?.MoveTransport(Direction.Right);
|
||||
break;
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user