xxxxxxxxxx
55
class Mover {
constructor() {
this.pos = createVector(random(width), random(height));
this.vel = createVector(0, 0);
this.r = 38;
}
update() {
let mouse = createVector(mouseX, mouseY);
this.acc = createVector(
map(noise(tx), 0, 1, -2, 2), map(noise(ty), 0, 1, -2, 2));
this.vel.add(this.acc);
this.pos.add(this.vel);
this.vel.limit(1);
}
show() {
noStroke();
stroke(100)
fill(200);
circle(this.pos.x, this.pos.y, 48);
}
checkEdges() {
if (this.pos.y < 0) {
this.pos.y = height;
} else if (this.pos.y >= height) {
this.pos.y = 0;
}
if (this.pos.x < 0) {
this.pos.x = width;
} else if (this.pos.x >= width) {
this.pos.x = 0;
}
}
// checkEdges() {
// if (this.pos.y + this.r <= 0) {
// this.pos.y = height + this.r;
// } else if (this.pos.y - this.r >= height) {
// this.pos.y = 0 - this.r;
// }
// if (this.pos.x + this.r <= 0) {
// this.pos.x = width + this.r;
// } else if (this.pos.x - this.r >= width) {
// this.pos.x = 0 - this.r;
// }
// }
}