xxxxxxxxxx
43
function setup() {
createCanvas(400, 400);
}
var id = 0;
const objs = [];
var t = 0 ;
var dt= 0.05;
class Bob{
constructor(){
this.c = color(random()*255, random()*255, random()*255)
this.x = 200
this.id = ++id;
this.y = 200}
move() {
this.x += map(sin(noise(t))*noise(this.id,t, ), 0, 1, -1, 1)
this.y += map(noise(t, this.id), 0, 1, -1, 1)
}
render() {
fill(this.c)
circle(this.x, this.y, 10);
}
}
function draw() {
background(220);
if (random()> 0.9) {
objs.push(new Bob())
}
objs.map(function(obj){
obj.move()})
objs.map(function(obj){
obj.render()})
t+=dt;
}