xxxxxxxxxx
45
let bubbles = [];
let space = 10;
let total = 20;
let cols = total;
let rows = total;
let colSize;
let rowSize;
let a = 0;
function setup() {
createCanvas(800, 800, WEBGL);
noStroke();
colorMode(HSB);
ellipseMode(CENTER);
colSize = width / cols;
rowSize = height / rows;
for (let x = 0; x < cols; x++) {
bubbles[x] = [];
for (let y = 0; y < rows; y++) {
bubbles[x][y] = new Bubble(
colSize / 2 + x * colSize,
rowSize / 2 + y * rowSize,
colSize / 2 + x * colSize,
random(20),
x * 200 + y
);
}
}
}
function draw() {
background(0);
rotateX(a);
translate(-width / 2, -height / 2, -200);
for (let x = 0; x < cols; x++) {
for (let y = 0; y < rows; y++) {
bubbles[x][y].show();
bubbles[x][y].update();
}
}
a += 0.001;
}