xxxxxxxxxx
38
class Builder{
constructor(x, y, index){
this.pos = createVector(x, y);
this.vel = createVector(1, 0);
this.c = floor(random(cols.length));
this.col = color(cols[this.c]);
this.col.setAlpha(200)
this.index = index;
this.nchance = floor(random(10));
this.nscale = 500;
strokeWeight(1);
}
move(){
this.nf = noise(this.pos.x / this.nscale, this.pos.y / this.nscale, this.index / 10000);
this.vel.setHeading((this.nf * TWO_PI) * 4);
// this.vel.setMag(this.nf * 5)
this.pos.add(this.vel);
if(this.pos.x < 0){
builders[this.index] = undefined;
}
if(this.pos.y < 0){
builders[this.index] = undefined;
}
if(this.pos.x > width){
builders[this.index] = undefined;
}
if(this.pos.y > height){
builders[this.index] = undefined;
}
if(noise(this.pos.x / 800, this.pos.y / 800) > 0){
stroke(this.col);
point(this.pos.x, this.pos.y);
}
}
}