How can I move a Windows Forms control randomly?
By that I mean the control should move in all directions, different ankles.
[ I created a variable called Speed to determine its speed. ]
I tried splitting up the Speed into 2 different ratios and then calculate the movement.
Random a = new Random();
Random b = new Random();
Random c = new Random();
int xR = a.Next(1, 20);
int yR = b.Next(1, 20);
int xM = Convert.ToInt32(xR * (Speed / (xR + yR)));
int yM = Convert.ToInt32(yR * (Speed / (xR + yR)));
if(c.Next(0, 10) % 2 == 0)
{
xM = -xM;
}
if (c.Next(15, 35) % 2 == 0)
{
yM = -yM;
}
Left += xM;
Top += yM;
The problem is the the control always moves the same.