I'm trying to make a sort of aimtrainer and I want a button to randomly change location when you click on it. I managed to randomize the coordinates but the button always stays on 1 line (top left to bottom right). How can I have the button also 'spawn' on other places? Thx
'''
public partial class game : Form
{
Random x = new Random();
Random y = new Random();
public game()
{
InitializeComponent();
}
private void game_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
int cox = x.Next(100, 1800);
int coy = y.Next(100, 900);
button1.Location = new Point(cox, coy);
}
}
'''
Aucun commentaire:
Enregistrer un commentaire