Explications instructions C#
Bonjour,
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| public partial class Game : Form
{
public Game()
{
InitializeComponent();
}
private void Game_Load(object sender, EventArgs e)
{
lblDifficulty.Text = "Difficulty : " + Globals.Difficulty.ToString();
lblName.Text = Globals.Name.ToString();
pnlStart.Left = (this.Width / 2) - (pnlStart.Width / 2);
pnlStart.Top = (this.Height / 2) - (pnlStart.Height / 2);
PlaceBloks();
}
bool retry = true;
public void PlaceBloks()
{
for (int i = 0; i <= Globals.Difficulty * 10; i++)
{
retry = true;
while(retry ==true)
{
PictureBox wall = new PictureBox();
wall.BackColor = Color.Black;
wall.Size = new Size(20, 20);
Random ramdomNumber = new Random();
int x = ramdomNumber.Next((wall.Width / 2), (this.Width - wall.Width) / 2);
int y = ramdomNumber.Next((wall.Height / 2), (this.Height - wall.Height) * 2 - (wall.Height / 2));
Crash(x,y,"wall");
if (retry == false)
{
wall.Location = new Point(x, y);
wall.Visible = true;
Controls.Add(wall);
}
}
}
}
public void Crash(int x, int y, string sender)
{ }
} |
Dans le code ci-dessus pouvez vous m'expliquer que veulent dire les instructions suivantes :
Code:
1 2
| int x = ramdomNumber.Next((wall.Width / 2), (this.Width - wall.Width) / 2);
int y = ramdomNumber.Next((wall.Height / 2), (this.Height - wall.Height) * 2 - (wall.Height / 2)); |
Code:
Controls.Add(wall);
Code:
1 2
| pnlStart.Left = (this.Width / 2) - (pnlStart.Width / 2);
pnlStart.Top = (this.Height / 2) - (pnlStart.Height / 2); |
Merci de m'aider.