xxxxxxxxxx
105
let adjective, music, button, coolGenre, coolName = [], prices = [], total;
let genreData = [];
let adjectiveData = [];
let crazy = 0;
let r=100
let g=100
let b=100
function preload() {
genreData = loadJSON('genres.json');
adjectiveData = loadJSON('adj.json');
foodData = loadJSON('food.json');
}
function setup() {
console.log('loading json data');
createCanvas(600, 400);
// noCanvas();
button = createButton('Impossible food');
button.mousePressed(giveName);
createP();
// button1 = createButton('2');
// button1.mousePressed(reset);
// coolGenre = createP (adjective + ' ' + music);
// print(data);
}
function draw() {
background(r,g, b, 50);
fill(255);
textSize(26);
text("IMPOSSIBLE JOE S", width/3, 50)
for(i=0; i <12; i++){
texty = coolName[i];
text(texty, (10) + (random(crazy)), (i*25)+80 + (random(crazy)));
}
// text(coolName, (10) + (random(crazy)), (height / 3+22) + (random(crazy)));
for(i=0; i <12; i++){
text(prices[i], width-90, (i*25)+80 + (random(crazy)));
}
text(total, width-90, height-10, (random(crazy)));
}
function genFood(){
adjective = adjectiveData.adjs[floor(random(adjectiveData.adjs.length))];
music = genreData.genres[floor(random(genreData.genres.length))];
food=foodData.genres[floor(random(foodData.genres.length))];
return(adjective+ ' '+music + ' '+ food);
}
function processGenre(genres) {
genreData = genres;
console.log('genre done');
console.log(genreData);
}
function processAdj() {
console.log('adj done');
}
function genPrice(){
// price = 1
price = floor(random(6));
price = price + 2
price = price-((floor(random(100)))/100);
price = price-0.01
return(price);
}
function giveName() {
for(i=0; i<12; i++){
coolName[i] = (genFood());
}
for(i=0; i<12; i++){
prices[i] = (genPrice());
}
total = prices[1]+prices[2]+prices[3]+prices[4]+prices[5]+prices[6]
r = random(150);
g = random(150);
b = 0;
return(coolName);
// crazy++;
// coolGenre.html (adjective + ' ' + music);
}
function reset(){
crazy=0
}