Move a Picture box at random coordinates while it is not yet clicked [Resolved]

Posted by Babyeney under C# on 7/25/2011 | Points: 10 | Views : 2685 | Status : [Member] | Replies : 1
I don't know how to add a for loop or while loop with the condition of: having the picture box move at random coordinates while it is not yet clicked by a mouse.

Random r = new Random();
int x;
int y;

public frmGame()
{
InitializeComponent();
MovePictureBox();
}

private void MovePictureBox()
{
int[] numbers = GenerateRandomNumbers();
picMonkey.Location = new Point(numbers[0], numbers[1]);
}

private int[] GenerateRandomNumbers()
{
int[] RandomNumbers = new int[2];
RandomNumbers[0] = r.Next(0, x);
RandomNumbers[1] = r.Next(0, y);
return RandomNumbers;
}

private void btnOptions_Click(object sender, EventArgs e)
{
frmGameOption frmGameOption = new frmGameOption();
frmGameOption.Show();
}
}




Responses

Posted by: Vforvijay on: 7/26/2011 [Member] Starter | Points: 50

Login to post response