xxxxxxxxxx
let Walker_obj;
function setup() {
walker_obj = new Walker();
createCanvas(windowWidth, windowHeight);
background(10);
}
function draw() {
var r = random(windowWidth/2 - 50 ,windowWidth/2 - 50 + 50);
//ellipse(windowWidth/2, windowHeight/2, 20, 20);
// Create walker
walker_obj.render();
walker_obj.step();
}
class Walker
{
// CONSTRUCTOR
constructor()
{
this.x = windowWidth/2;
this.y = windowHeight/2;
this.mean = 0;
this.std_dev = 0;
print("walker constructed");
} // END CONSTRUCTOR
// FUNCTION
render()
{
noStroke();
fill(255,10);
//point(this.x, this.y);
ellipse(this.x, this.y, 20, 20);
}
step()
{
// Pure random. Equal probability
// var r = random() * width;
// this.x = r;
// Gaussian Random. Random numbers cluster around a mean value occasionally choosing outlier values
this.mean = windowWidth/2;
this.std_dev = 50;
var gauss_r = randomGaussian(this.mean,this.std_dev);
this.x = gauss_r;
}
}// END CLASS