xxxxxxxxxx
50
const BALL_SPEED = 5;
const BALL_SIZE = 30;
const BALL_AGE = 1000;
const RAND_COLOR_MAX = 255;
const BACKGROUND_HEX = "#B7EDFF";
const balls = [];
class Ball {
constructor(x, y, dir, col) {}
draw() {}
move() {}
run() {}
}
function setup() {
createCanvas(windowWidth, windowHeight);
let col = [
random(0, RAND_COLOR_MAX),
random(0, RAND_COLOR_MAX),
random(0, RAND_COLOR_MAX),
150
];
let ball = new Ball(
random(10, windowWidth - 10),
random(10, windowHeight - 10),
random(0, 360),
col
);
balls.push(ball);
}
function draw() {
background(BACKGROUND_HEX);
balls.forEach(b => b.run());
}
function mouseDragged() {
let col = [
random(0, RAND_COLOR_MAX),
random(0, RAND_COLOR_MAX),
random(0, RAND_COLOR_MAX),
150
];
let b = new Ball(mouseX, mouseY, random(0, 360), col);
balls.push(b);
}