xxxxxxxxxx
53
class Rain {
constructor (nDrops,wSpeed) {
this.acceleration = 0.2;
this.nDrops = nDrops;
this.angle = 0;
this.offset = 1/2 * width;
this.scalar = 40;
this.wSpeed = wSpeed;
}
dropset() {
this.initX = function() {
this.x = random() * width/3 + width/3;
}
this.initY = function() {
this.y = -random() * height/3 + height/2;
}
this.length = random()*10;
this.speed = random ();
}
drawAndDrop () {
this.display();
this.drop();
}
display() {
stroke(255,255,255,90);
strokeWeight(random(1,3));
line(this.x, this.y, this.x, this.y + this.length);
}
drop() {
this.dropset();
if (this.y < height) {
this.y += this.speed;
this.speed += this.acceleration;
} else {
this.speed = random();
this.initY();
this.initX();
}
// this.angle += this.wSpeed;
// this.yMove = -90 + sin(this.angle)*this.scalar;
// image(this.clouds, 200,this.yMove,200,200/1.5);
}
}