xxxxxxxxxx
32
let object; //declare object
function setup() {
createCanvas(400, 400);
//create object
object = new Jitter();
}
function draw() {
background(220);
object.move();
object.show();
}
//Jitterclass
class Jitter {
constructor() {
this.x = random(width);
this.y = random(height);
this.diameter = random(10, 30);
this.speed = 1;
}
move() {
this.x += random(-this.speed, this.speed);
this.y += random(-this.speed, this.speed);
}
show() {
ellipse(this.x, this.y, this.diameter, this.diameter);
}
}