xxxxxxxxxx
int num = 700;
Particle [] floaterS = new Particle [num];
float hitDistance = 10;
void setup() {
size( 600, 800);
for (int i = 0; i < num; i++) {
floaterS[i] = new Particle(random(width), random(height));
floaterS[i].gravity = new PVector(0, -.1);
floaterS[i].fillColor = color(0, 255, 255);
}
}
void draw() {
background(0);
hitBox();
for (int i = 0; i < num; i++) {
floaterS[i].update();
//floaterS[i].display();
}
}
void hitBox () {
//draw hitbox around the particle
//fill(247, 17, 144, 80);
fill(255, 255, 0, 40);
//strokeWeight(6);
//stroke(247, 17, 144);
for (int i = 0; i < num; i++) {
//ellipse(floaterS[i].pos.x, floaterS[i].pos.y, 10, 10);
// line(floaterS[i].pos.x, floaterS[i].pos.y, floaterS[i].pos.x+random(50), floaterS[i].pos.y+random(50));
bezier(floaterS[i].pos.x, floaterS[i].pos.y, floaterS[i].pos.x+random(50), floaterS[i].pos.y+random(50), floaterS[i].pos.x+random(50), floaterS[i].pos.y+random(50),floaterS[i].pos.x+random(50), floaterS[i].pos.y+random(50));
}
}
void mousePressed() {
//on mouse click, add force to object
for (int i = 0; i < num; i++ ) {
if ( dist(mouseX, mouseY, floaterS[i].pos.x, floaterS[i].pos.y) < hitDistance+10) {
floaterS[i].addForce( 0, 10 );
}
}
//// on mouse click, move away from the mouse
//for (int i = 0; i < num; i++) {
// if (dist (mouseX, mouseY, floaterS[i].pos.x, floaterS[i].pos.y) < hitDistance+10) {
// floaterS[i].addForce((floaterS[i].pos.x - mouseX)*0.03, (floaterS[i].pos.y - mouseY)*0.03);
// }
//}
}