xxxxxxxxxx
96
let walkerSpeed = 5;
walkers = []
function setup() {
createCanvas(400, 400, WEBGL);
easycam = createEasyCam();
easycam = new Dw.EasyCam(this._renderer, {distance:620, center:[0,0,0]});
walking = new Walker(0,0);
}
function draw() {
background(0);
push();
noStroke();
fill(0,0,255, 200);
translate(0,0,-60);
sphere(100);
pop();
push();
translate(0,0,100);
noStroke();
fill(255,0,0,100);
walking.display(255,0,0);
walking.steps();
walking.border();
let storeWalk = new Walker(walking.x, walking.y);
walkers.push(storeWalk);
for(var i =0; i<walkers.length; i++){
fill(255, 1);
circle(walkers[i].x,walkers[i].y,200);
}
if(walkers.length>1000){
walkers.shift();
}
pop();
}
let Walker = class{
constructor(x, y){
this.x = x;
this.y = y;
}
display(r, g, b){
//stroke(r,g,b,5);
//strokeWeight(100);
//point(x,y);
//strokeWeight(2);
noStroke();
fill(r,g,b, 5);
circle(this.x,this.y,100);
}
steps(){
let stepx = random(-1,1);
let stepy = random(-1,1);
//int stepx = int(random(-2,2));
//int stepy = int(random(-2,2));
//if(!communication){
this.x = this.x+walkerSpeed*stepx;
this.y = this.y+walkerSpeed*stepy;
//}else{
// x = x+map(valueRAW,0,1,10,30)*stepx;
// y = y+map(valueRAW,0,1,10,30)*stepy;
//}
//x = constrain(x, 0,screenWidth);
//y = constrain(y, 0,screenHeight);
}
border(){
if(this.x<0) this.x=windowWidth;
if(this.x>width) this.x=0;
if(this.y<0) this.y=windowHeight;
if(this.y>height) this.y=0;
}
walking(){
//steps();
//border();
}
}