xxxxxxxxxx
49
let t = 0;
let tx = 0;
class Walker {
constructor() {
this.pos = createVector(width / 2, height / 2);
}
update() {
let stepsize = 10
this.vx = noise(t / 10);
this.vy = noise((10000 + t) / 10);
this.vx = map(this.vx, 0, 1, -stepsize, stepsize);
this.vy = map(this.vy, 0, 1, -stepsize, stepsize);
// this.vel = createVector(this.vx, this.vy);
this.vel = createVector();
this.pos.add(this.vel);
if (this.pos.x > width) {
this.pos.x = 0;
} else if (this.pos.x < 0) {
this.pos.x = width;
}
if (this.pos.y > height) {
this.pos.y = 0;
} else if (this.pos.y < 0) {
this.pos.y = height;
}
}
show() {
circle(this.pos.x, this.pos.y, 46);
}
}
function setup() {
createCanvas(400, 400);
background(20);
walker = new Walker();
}
function draw() {
t++;
walker.update();
walker.show();
}