random values
in
Programming Questions
•
2 years ago
does anyone know how I can extract a specific number or number position from a random value list?
...Right now I have 5 attractors and I wana extract x,y coordinates for each attractor
here is my part of code where I need that
thank you
class Attractor {
int type;
float rad;
float x, y;
int col;
Attractor(int type, float rad, int col) {
this.type = type;
this.rad = rad;
this.col = col;
this.x = random(width);
this.y = random(height);
// float [] x = {random(width)};
// float [] y ={random(height)};
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
void move() {
float d = dist(mouseX, mouseY, x, y);
float r = 10;
if(d < rad && abs(mouseX-pmouseX) > 0) {
noFill();
beginShape();
endShape();
stroke(255, 50);
ellipse(x, y, r/8, r/8);
noStroke();
fill(col, 155, 155, 55);
ellipse(x, y, r, r);
if(dragged == this){
x = mouseX;
y = mouseY;
}
}
}
...Right now I have 5 attractors and I wana extract x,y coordinates for each attractor
here is my part of code where I need that
thank you
class Attractor {
int type;
float rad;
float x, y;
int col;
Attractor(int type, float rad, int col) {
this.type = type;
this.rad = rad;
this.col = col;
this.x = random(width);
this.y = random(height);
// float [] x = {random(width)};
// float [] y ={random(height)};
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
void move() {
float d = dist(mouseX, mouseY, x, y);
float r = 10;
if(d < rad && abs(mouseX-pmouseX) > 0) {
noFill();
beginShape();
endShape();
stroke(255, 50);
ellipse(x, y, r/8, r/8);
noStroke();
fill(col, 155, 155, 55);
ellipse(x, y, r, r);
if(dragged == this){
x = mouseX;
y = mouseY;
}
}
}
1
