xxxxxxxxxx
62
/*
Art + Code
This code uses the coding concepts of arrays to create a virtual simulation of the Untitled candy works by Félix González-Torres. In the installations, a pile of candies representing the artist's lover are depleted throughout the day by visitors taking the pieces of candy. Here virtual versions of the candy start in a pile and slowly move away one by one.
To reset, press any key!
*/
let candyX = [];
let candyY = [];
let candyXS = [];
let candyYS = [];
function setup() {
createCanvas(windowWidth, windowHeight);
// frameRate(24);
for (let i = 0; i < 200; i++) {
candyX.push(random(100, 200));
candyY.push(random(100, 400));
candyXS.push(random(.1, 2));
candyYS.push(random(.1, 2));
}
}
function keyPressed() {
replenish();
}
function replenish() {
for (let i = 0; i < 50; i++) {
candyX.push(random(100, 200));
candyY.push(random(100, 400));
candyXS.push(random(.1, 2));
candyYS.push(random(.1, 2));
}
}
let howMany = 0;
function draw() {
background(245, 245, 245);
textSize(28);
for(let i = 0; i < candyX.length; i++) { // loop to display all of the circles
text("🍬", candyX[i], candyY[i]);
}
for(let i = 0; i < howMany; i++) {
candyX[i] += candyXS[i];
candyY[i] += candyYS[i];
}
if (frameCount % 20 === 0) {
howMany++;
console.log(howMany);
}
}