xxxxxxxxxx
36
var cricket, spider, beetle;
function setup(){
createCanvas(200,200);
noStroke();
cricket = new Bug();
spider = new Bug();
}
function draw(){
background(120);
cricket.moveBug();
spider.moveBug();
cricket.drawBug();
spider.drawBug();
}
class Bug {
constructor() {
this.c = color(random(255),random(255),random(255));
this.x = random(width);
this.y = random(height);
}
moveBug(){
this.x = this.x+random(-1,1);
this.y = this.y+random(-1,1);
}
drawBug(){
fill(this.c);
ellipse(this.x,this.y,20,20);
}
}