xxxxxxxxxx
29
class Mover3 {
constructor(x, y, m) {
this.pos = createVector(x, y);
this.vel = p5.Vector.random2D();
this.vel.mult(3);
this.acc = createVector(0, 0);
this.mass = m;
this.r = sqrt(this.mass) * 2;
}
applyForce(force) {
let f = p5.Vector.div(force, this.mass);
this.acc.add(f);
}
update() {
this.vel.add(this.acc);
this.pos.add(this.vel);
this.acc.set(0, 0);
}
show() {
stroke(224, 246, 253, 150); //adjust color
strokeWeight(2);
fill(255, 20);
ellipse(this.pos.x / 0.63, this.pos.y / 0.63, this.r * 3);
}
}