xxxxxxxxxx
var w;
function setup() {
createCanvas(windowWidth,windowHeight);
w = new Walker();
}
function draw() {
background(51);
w.update();
w.display();
}
function Walker(){
this.pos = createVector(width/2, height/2);
this.vel = createVector(0, 0);
this.update = function(){
// this.acc = createVector(random(-1,1), random(-1,1));
this.acc = p5.Vector.fromAngle(random(TWO_PI));
// this.acc.mult(0.1);
// var mouse = createVector(mouseX, mouseY);
// this.acc = p5.Vector.sub(mouse, this.pos);
// this.acc.normalize();
// this.acc.mult(0.01);
this.acc.setMag(0.05);
this.vel.add(this.acc);
this.pos.add(this.vel);
}
this.display = function(){
fill(240);
ellipse(this.pos.x, this.pos.y, 50, 50);
}
}