xxxxxxxxxx
let Ichi = [];
let Ugoki = [];
const NUM = 10;
function setup() {
background(100);
createCanvas(windowWidth, windowHeight);
frameRate(15)
for ( i = 0; i < NUM; i++){
Ichi[i] = createVector(width/2,height/2);
Ugoki[i] = createVector(random(-10,10),random(-10,10));
}
}
function draw() {
noStroke();
fill(random(200,255),random(100,255),random(100,120),150);
for (let i = 0; i < NUM; i++){
ellipse(Ichi[i].x,Ichi[i].y,10,20);
Ichi[i].add(Ugoki[i]);
if (Ichi[i].x < 0 || Ichi[i].x > width){
Ugoki[i].x = Ugoki[i].x * -1;
}
if (Ichi[i].y < 0 || Ichi[i].y > height){
Ugoki[i].y = Ugoki[i].y * -1;
}
}
}