xxxxxxxxxx
39
let array=[];
let sarray=[];
function setup() {
createCanvas(600, 400);
for(i=0;i<52;i++){
array.push(new ObjectMaker());
//sarray.push( new ObjectMaker());
}
}
function draw() {
noStroke();
background(220+random(2));
for(i=0;i<array.length;i++){
array[i].doStuff()}
}
class ObjectMaker{
constructor(){
this.x=random(width);
this.y=random(height);
this.s=random(1,20);
}
doStuff(){
rectMode(RADIUS);
fill(this.y,this.x,100);
rect(this.x,this.y,24,10);
this.x=this.x+this.s;
if(this.x>width || this.x<0){
this.s=this.s*-1;}
fill(100,this.x,100);
ellipse(this.x,this.y,24);
this.x=this.x+this.s;
if(this.x>width || this.x<0){
this.s=this.s*-1;}
}
}