xxxxxxxxxx
137
let fortunes = [
"Have a cookie on me!",
"Your financial situation \nwill soon improve.",
"You have been slacking.\nThat is okay.",
"Is Mercury in retrograde?\nAre you in retrograde?",
"Keep enemies close,\nkeep friends closer.",
"Follow your dreams.",
"Live Love Laugh.\nI mean it.",
"You must be brave.",
"Your loneliness will not end.\nIt will find company.",
"They will text you back.",
"Your mother loves you\nin secret.",
"We will never be good",
"Time cannot be created \nor destroyed.",
"What is the cost of living?",
"Eat!",
"Time to forget your name.",
"Do you actually fear death?",
"Repeat",
"Winter is coming.\nSo is summer.",
"Your children will die, too.",
"Drink water.",
"~meow~",
"What are the conditions\n of worth?",
"Can I sit on top of you?",
"Who even read anymore?",
"$8.57 maple cardamom\noatmilk lavender latte",
"Wealth creates Poverty.",
"Do you believe reality?",
""
];
let currentFortune = "";
let fortuneButton;
let resetButton;
let creditButton;
let cookie;
let textbox;
let showText = true;
function preload() {
cookie = loadImage("cookie.png");
textbox = loadImage("scroll.png");
}
function setup() {
createCanvas(400, 400);
fortuneButton = createButton("~ Crack that Cookie ~");
fortuneButton.position(120, 300);
fortuneButton.style('background-color', '#ffcc00');
fortuneButton.mousePressed(pickFortune);
resetButton = createButton("~ Ask for Another Cookie ~");
resetButton.position(97, 300);
resetButton.style('background-color', '#ffcc00');
resetButton.hide();
resetButton.mousePressed(resetSketch);
creditButton = createButton("credits");
creditButton.style('font-size', '10',);
creditButton.style('background-color', 'transparent');
creditButton.style('border', 'none');
creditButton.style('outline', 'none');
creditButton.position(330, 355);
creditButton.hide();
creditButton.mousePressed(credit);
selectAll('button').forEach(button => {
button.style('font-family', 'Papyrus');
button.style('font-size', '15px');
});
}
function draw() {
textAlign(CENTER);
background(255,105,105);
if (showText === true){
if (currentFortune === "") {
image(cookie, 50, 50, 300, 200);
}else {
image(textbox, 50, 50, 300, 200);
}
fill(0);
textSize(15);
text(currentFortune, 200, 150);
}
else {
textSize(20);
text("Fortune", 200, 100);
textSize(15);
text("Susie Xu", 200, 150);
text("For Scripting is Scrying 2024", 200, 180);
text("Coding Instructions by Aarati and Erica", 200, 195);
textSize(10);
text("Cookie Image: https://images.app.goo.gl/Tw2y14q3nubPYbbu6", 200, 210);
text("Text Box: https://images.app.goo.gl/hozanNaFGy8vJ9Xc9", 200, 240);
}
}
function mousePressed() {
if (mouseX > 50 && mouseX < 350 &&
mouseY > 50 && mouseY < 250 &&
currentFortune === "") {
pickFortune();
}
}
//this is supposed to make image clickable on iphones
//not working
function touchStarted() {
checkImageClicked(touchX, touchY);
}
function pickFortune() {
currentFortune = random(fortunes);
fortuneButton.hide();
resetButton.show();
creditButton.show();
}
function resetSketch(){
showText = true;
currentFortune = "";
fortuneButton.show();
resetButton.hide();
creditButton.hide();
}
function credit(){
showText = false;
textAlign(CENTER);
}