xxxxxxxxxx
56
let xPos = [];
let yPos = [];
let blues = [];
let speeds = [];
function setup() {
createCanvas(400, 400);
var count = 0;
for (let i = 0; i < 100; i++){
append(xPos,random(0,400));
append (yPos,random(-200,200));
append(blues, random(100,256));
append(speeds,random(0.5,2));
count++;
}
noStroke();
}
function draw() {
background(0,0,50,25);
for (let i = 0; i < xPos.length;i++){
fill(0,0,blues[i]);
ellipse(xPos[i],yPos[i],10,10);
yPos[i]++;
if (yPos[i]>400){
yPos[i] = 0;
}
if (xPos[i]>400){
xPos[i] = 0;
}
if (xPos[i]<0){
xPos[i] = 400;
}
if (keyIsDown(DOWN_ARROW)){
yPos[i]++;
yPos[i]++;
}
if (keyIsDown(UP_ARROW)){
yPos[i]--;
yPos[i]--;
yPos[i]--;
yPos[i]--;
}
if (keyIsDown(LEFT_ARROW)){
xPos[i]--;
xPos[i]--;
}
if (keyIsDown(RIGHT_ARROW)){
xPos[i]++;
xPos[i]++;
}
}
}