xxxxxxxxxx
32
let cell=[];
let cellNum=20;
class Cell{
constructor(){
this.x= randomGaussian(width/2,30)
this.y=height-10; //starts from bottom bar
}
show(){
noStroke();
fill(0,random(200),100,120);
ellipse(this.x,this.y,10,10);
}
grow(){
let lean=map(mouseX-width/2,width/-2,width/2,-3,3);
this.x=this.x+random(lean-3*abs(lean),lean+3*abs(lean));
this.y=this.y-random(1,2);
}
}
function setup() {
createCanvas(400, 550);
for(var i=0;i<cellNum;i++){
cell[i]= new Cell();
}
}
function draw() {
for(var i=0;i<cellNum;i++){
cell[i].show();
cell[i].grow();
}
}
//mouse movement as the waterflow