xxxxxxxxxx
32
/*
1. Code below is for https://vimeo.com/channels/learningp5js/141211396
2. Video reference at 0:20 seconds on Objects > https://vimeo.com/channels/learningp5js/138327558
3. This sketch is from 8:00 minute of the video covering words in arrays and the arrays.length function
*/
var words = ["rainbow", "heart", "purple", "friendship", "love"];
var index = 0;
function setup() {
createCanvas(400, 400);
}
function draw() {
background(0);
fill(255);
textSize(32);
text(words[index], 12, 200);
}
function mousePressed() {
index = floor(random(words.length));
console.log(index);
if (index == words.length) {
index = 0;
}
}