xxxxxxxxxx
83
let allNodes = [];
function push_message(_x,_y,_str){
allNodes.push(new aNode(_x,_y,_str));
snd.amp(.5);
snd.rate(.8+random());
snd.play();
}
function operateNodes(){
for(let i=0;i<allNodes.length;i++){
let cn = allNodes[i];
cn.updateMe();
if(cn.age<.1){
//this.remove();
allNodes.splice(i, 1);
//remove(cn);
delete cn;
}
}
//console.log(allNodes.length);
}
class aNode{
constructor(x, y, str) {
this.age = 1.0;
this._x = x;
this._y = y;
this._str = str;
this.a = 0;
}
updateMe(){
this.age *=.93;
this.a = angle(this._x*width,this._y*height,width/2,height/2);
let cdist = dist(this._x,this._y, 0.5, 0.5);
if(cdist> .3 ){
this._str = "👆";
}
textSize(this.age*80+12);
textAlign(CENTER);
push();
translate(this._x*width,this._y*height);
rotate( this.a -HALF_PI );
text(this._str,0,0);
pop();
}
}
function angle(p1x,p1y,p2x,p2y){
return Math.atan2(p2y - p1y, p2x - p1x);
}