I’m trying to create a program where 1st a ball is randomly placed and when clicked on, the old one is removed and a new one is placed randomly. The problem is that even though I do random() again for that variable it doesn’t refresh the number used and it just stays the same.
target t;
float fx;
float fy;
int ix = int(fx);
int iy = int(fy);
int p = 0;
void setup() {
background(255);
size (800, 600);
t = new target();
t.newtarget();
cursor(CROSS);
}
void draw() {
}
void mousePressed() {
if (dist(mouseX, mouseY, ix, iy) < 50) {
background(255);
println("success");
p = p + 1;
println(p);
t.newtarget();
}
}
//target class
class target {
void newtarget() {
fx = random(780);
fy = random(580);
fill(0, 255, 0);
ellipse(ix, iy, 50, 50);
}
}
Any help is wanted