xxxxxxxxxx
71
let Font1;
let Font2;
//I declared variables up here so they are global. At the moment you had them as local variables in setup, which wouldn't let them work in other parts of the code
let r;
let g;
let b;
let randomword1;
let randomword2;
let randomword3;
function preload () {
Font1 = loadFont ('ToThePointRegular-n9y4.ttf');
Font2 = loadFont ('ChrustyRock-ORLA.ttf'
)
}
var word1 = ['pastry', 'turtle', 'rocket', 'vampire', 'angry', 'spicy', 'red hot', 'hotline', 'bouncy', 'neurotic', 'gen - z', 'emo', 'Japanese', 'yoga', 'frantic', 'silky']
var word2 = ['babies', 'sisters', 'fish', 'dads', 'pandas', 'coconuts', 'peppers', 'sharks', 'koalas', 'ninjas', 'racoons', 'grandmas', 'croissants', 'professors', 'ghosts', 'scamps']
var word3 = ['xylophone', 'keyboard guitar', 'spoons', 'bongos', 'chalkbaord', 'triangle', 'popcorn machine', 'neighbours cat', 'whalesong', 'dad sneeze', 'fire alarm', 'police siren', 'wet sock', 'whoopee cushion', 'crack whip', 'megaphone', 'hairdryer']
function setup() {
createCanvas (600,600);
//Select first background colour
r = random(255);
b = random(255);
g = random(255);
background (r,g,b);
//Select first words
randomword1 = random(word1);
randomword2 = random(word2);
randomword3 = random(word3);
}
function draw() {
background(r,g,b);
textFont(Font1);
textSize(60)
//static text
text ('Your band name should be', 130,210)
text ('the', 130, 255)
line (200,260, 340, 260)
line (360,260, 500, 260)
//line2
text ('Your instrument of choice', 130,330)
text ('is the', 135, 375)
line (230,380, 500, 380)
//noLoop() was not letting it reset, so I rearranged variables
//noLoop();
//random words below
textFont(Font2);
textSize (35)
text (randomword1, 200, 255);
text (randomword2, 360, 255);
text (randomword3, 230, 380);
}
//Instead of mousePressed, which requires a conditional statement, I added the mouseClicked function
function mouseClicked(){
r = random(255);
b = random(255);
g = random(255);
randomword1 = random(word1);
randomword2 = random(word2);
randomword3 = random(word3);
}