xxxxxxxxxx
29
var xpositions = [25, 48, 97, 155];
console.log("xpositions: " + xpositions);
function setup() {
createCanvas(400, 400);
background(255, 255, 240);
// we are going to use push to add 3 random numbers between 200 and 400 to the array xpositions
xpositions.push( random(200,400) );
xpositions.push( random(200,400) );
xpositions.push( random(200,400) );
console.log("xpositions after adding random numbers: " + xpositions);
}
function draw() {
// can you draw circles using the other values of the array xpositions?
fill(255, 0, 0);
ellipse(xpositions[0], 100, 20, 20);
ellipse(xpositions[3], 100, 20, 20);
fill(0, 0, 255);
ellipse(xpositions[5], 100, 20, 20);
ellipse(xpositions[6], 100, 20, 20);
ellipse(xpositions[7], 100, 20, 20);
}