xxxxxxxxxx
58
class Walker {
constructor(x, y, index){
this.pos = createVector(x, y);
this.vel = createVector(1, 0);
this.acc = createVector(2, 0);
this.acc2 = createVector(1, 0);
this.vel.setMag(random(3));
this.acc.setMag(random(3));
this.acc2.setMag(random(3));
this.index = index;
this.c = floor(random(cols.length));
this.col = color(cols[c]);
angleMode(DEGREES);
this.vel.setHeading(random(360));
this.acc.setHeading(random(360));
this.va = 0;
this.aa = 0;
this.va1 = 0.01;
this.aa1 = 0.0275;
this.w = 2;
this.npos = undefined;
}
update() {
this.va = this.va + this.va1;
this.aa = this.aa + this.aa1;
this.vel.setHeading(this.va);
this.acc.setHeading(this.aa);
this.vel.add(this.acc);
this.vel.limit(6);
this.npos = p5.Vector.add(this.pos, this.vel);
stroke(0);
strokeWeight(2);
line(this.pos.x, this.pos.y, this.npos.x, this.npos.y);
this.pos.add(this.vel);
this.w = this.vel.mag();
if(this.pos.x > width){
this.pos.x = 0;
}
if(this.pos.y > height){
this.pos.y = 0;
}
if(this.pos.x < 0){
this.pos.x = width;
}
if(this.pos.y < 0){
this.pos.y = height;
}
}
show() {
// this.col = color(cols[this.c]);
// // this.col.setAlpha(10);
// stroke(this.col);
// strokeWeight(2);
// point(this.pos.x, this.pos.y);
}
}