xxxxxxxxxx
28
class Gota {
constructor() {
this.pos = createVector(0, 0)
this.randomDir();
}
randomDir() {
let dispersion = 0.1;
this.dir = p5.Vector.fromAngle( - random(HALF_PI - dispersion, HALF_PI + dispersion));
this.dir.setMag(random(0, 9));
}
mueve() {
this.pos.add(this.dir);
this.dir.add(gravedad);
if (this.pos.y > 0) {
this.pos.mult(0);
this.randomDir();
}
}
dibuja() {
stroke(color('aqua'), (this.pos.y * -2));
strokeWeight(2);
point(this.pos.x, this.pos.y);
}
}