xxxxxxxxxx
58
//why are the colors not changing at the time but everytime I replay it?
//maybe add a car window
var xPos = [];
var yPos = [];
var blueish = [];
var windows;
//var speeds = [];
function preload() {
windows = loadImage('1-1.jpg');
}
function setup() {
createCanvas(400, 400);
windows = loadImage('1-1.jpg');
var count = 0;
while (count < 18) {
append(xPos,random(400));
append(yPos,random(400));
append(blueish,random(256));
//append(speeds,random(0.5,2));
count++;
}
}
function draw() {
background(180,180,200,10);
noStroke();
var i = 0;
fill(0,0,blueish[i]);
//image(windows,0,0);
while (i < xPos.length) {
ellipse(xPos[i],yPos[i],10,20);
yPos[i]++;
xPos[i]++;
//this code makes it fade to the maxiumum every time
if(yPos[i] > 410) {
blueish[i] = random(100,256);
yPos[i] = random(-50,200);
xPos[i] = random(-50,200);
} else if (xPos[i] > 410) {
blueish[i] = random(100,256);
yPos[i] = random(-50,400);
xPos[i] = random(-50,200);
} else if (xPos[i] > 410) {
yPos[i] = random(0,400)
}
if (yPos[i] > 0) {
xPos[i] = xPos[i] + random(-2,2);
}
//do one of these if statements for blueish
i++; //same meaning as i = i + 1;
}
stroke("black");
fill("white");
rect(180,0,50,400);
rect(0,180,400,50);
}