let URL = 'https://docs.google.com/spreadsheets/d/e/2PACX-1vQVcU0ZM1ZI7hCegT7v8ncgZVR8k7m1RBKDeTRDzSCPNLEo1-eeOlyiyd231kZjCK4l0uRZUNFg5-Zq/pub?output=csv'
let preX, preY, postX, postY, startX, startY, endX, endY
let adjective1, placeName1, adjective3, noun1, verb1, adjective4, animal, adjective5, adjective6, noun2;
let verb2, adjective7, adjective8, adjective9, adjective10, mythicalCreature, noun3, number;
let pastTenseVerb1, pastTenseVerb2, adjective11;
table = loadTable(URL, 'csv', 'header');
readerBot = loadImage('Drawing-33.sketchpad.png')
console.log = function() {};
createCanvas(windowHeight, windowHeight)
readerBot.resize(height, 0)
speech = new p5.Speech();
lookDown = height * 0.258
function getRandomWord(columnName) {
let column = table.getColumn(columnName);
rect(width * 0.38, height * 0.31, width * 0.23, height * 0.1)
let aOsc = sin(frameCount / 2)
let bOsc = cos(frameCount / 10)
let cOsc = cos(frameCount / 2)
let dOsc = sin(frameCount / 10)
let changer = map(noise(frameCount / 100), 0, 1, 0.005, 1.125)
preX = map(aOsc, -1, 1, 0, width)
preY = map(bOsc, -1, 1, height * 0.25, height * 0.5)
postX = map(cOsc, -1, 1, width, 0)
postY = preY = map(dOsc, -1, 1, height * 0.25, height * 0.5)
stroke(map(dOsc, -1, 1, 200, 255), 100, 0)
strokeWeight(3 + changer * 2)
preX = map(dOsc, -1, 1, 0, width)
preY = map(cOsc, -1, 1, height * 0.25, height * 0.5) * changer
postX = map(bOsc, -1, 1, width, 0)
postY = preY = map(aOsc, -1, 1, height * 0.25, height * 0.5) * changer
stroke(0, 200, map(aOsc, -1, 1, 200, 255))
strokeWeight(3 + changer * 3)
reading = sin(frameCount / 50) * 30
leftOfLeft = width * 0.35
rightOfLeft = width * 0.43
leftOfRight = width * 0.55
rightOfRight = width * 0.63
point(width * 0.59 + reading, lookDown)
point(width * 0.39 + reading, lookDown)
line(startX, startY, endX, endY)
point(width * 0.59, lookDown * 0.95)
point(width * 0.39, lookDown * 0.95)
let mouseXFraction = mouseX / width;
let mouseYFraction = mouseY / height;
print("Mouse X: " + mouseXFraction.toFixed(2) + ", Mouse Y: " + mouseYFraction.toFixed(2));
const adjective1 = getRandomWord('adjective1');
const placeName1 = getRandomWord('placeName1');
const adjective3 = getRandomWord('adjective3');
const noun1 = getRandomWord('noun1');
const verb1 = getRandomWord('verb1');
const adjective4 = getRandomWord('adjective4');
const animal = getRandomWord('animal');
const adjective5 = getRandomWord('adjective5');
const adjective6 = getRandomWord('adjective6');
const noun2 = getRandomWord('noun2');
const verb2 = getRandomWord('verb2');
const adjective7 = getRandomWord('adjective7');
const adjective8 = getRandomWord('adjective8');
const adjective9 = getRandomWord('adjective9');
const adjective10 = getRandomWord('adjective10');
const mythicalCreature = getRandomWord('mythicalCreature');
const noun3 = getRandomWord('noun3');
const number = getRandomWord('number');
const pastTenseVerb1 = getRandomWord('pastTenseVerb1');
const pastTenseVerb2 = getRandomWord('pastTenseVerb2');
const adjective11 = getRandomWord('adjective11');
const storyChoice = Math.floor(Math.random() * 4) + 1;
madLibStory = `Once upon a time, in a ${adjective1} land called ${placeName1}, there lived a ${adjective3} ${noun1}. This ${noun1} loved to ${verb1} every day until one day, a ${adjective4} ${animal} appeared.\n\n` +
`“Wow!” said the ${noun1}. “You’re so ${adjective5}! What brings you here?”\n\n` +
`The ${animal} replied, “I am on a quest to find the ${adjective6} ${noun2}. It is said to grant anyone the power to ${verb2}. Will you help me?”\n\n` +
`Together, they set off on a journey through the ${adjective7} forest, across the ${adjective8} desert, and over the ${adjective9} mountains. Along the way, they encountered a ${adjective10} ${mythicalCreature} who challenged them to a ${noun3}-eating contest.\n\n` +
`“I hope you like ${noun3}!” said the ${mythicalCreature}.\n\n` +
`After ${number} rounds, they continued their journey. At last, they reached the ${noun2}, and with a ${adjective11} cheer, they ${pastTenseVerb2} into the sunset.\n\n` +
} else if (storyChoice === 2) {
madLibStory = `Deep in the ${adjective1} world of ${placeName1}, a ${adjective3} ${noun1} had a dream: to ${verb1} with a ${adjective4} ${animal}. One ${adjective5} morning, their wish came true!\n\n` +
`The ${animal} exclaimed, “I need your help! The ${adjective6} ${noun2} has been stolen by a ${adjective7} ${mythicalCreature}. We must ${verb2} to get it back!”\n\n` +
`So, they ${pastTenseVerb1} to the ${adjective8} castle, passed the ${adjective9} bridge, and snuck past the ${adjective10} guards. Inside, they found the ${mythicalCreature} guarding the ${noun2}.\n\n` +
`The ${mythicalCreature} growled, “If you want this ${noun2}, you must solve my riddle!”\n\n` +
`After ${number} attempts, they solved the riddle. With a ${adjective11} cheer, they ${pastTenseVerb2} all the way home.\n\n` +
} else if (storyChoice === 3) {
madLibStory = `In the ${adjective1} town of ${placeName1}, a ${adjective3} ${noun1} discovered a ${adjective4} map hidden under a ${noun3}. The map promised to lead to a ${adjective5} treasure guarded by a ${mythicalCreature}.\n\n` +
`Determined to ${verb1} the treasure, the ${noun1} set out on a journey. Along the way, they met a ${adjective6} ${animal} who joined the adventure.\n\n` +
`“The ${noun2} lies beyond the ${adjective7} sea,” said the ${animal}. Together, they sailed across the ${adjective8} waves and braved a ${adjective9} storm.\n\n` +
`Finally, they reached the ${adjective10} island where the ${mythicalCreature} awaited. With a clever trick, they ${pastTenseVerb1} the ${mythicalCreature} and claimed the treasure.\n\n` +
`They returned to ${placeName1} as ${adjective11} heroes. The end!`;
} else if (storyChoice === 4) {
madLibStory = `Long ago, a ${adjective1} ${noun1} lived near the ${adjective2} ${placeName1}. One day, while ${verb1} by the ${noun2}, they discovered a ${adjective3} bottle with a ${adjective4} note inside.\n\n` +
`The note read, “Help! I’m trapped in the ${adjective5} tower by a ${adjective6} ${mythicalCreature}. Please rescue me!” The ${noun1} and their ${adjective7} friend, a ${animal}, decided to ${verb2} to the rescue.\n\n` +
`Through the ${adjective8} woods and over the ${adjective9} hills, they ${pastTenseVerb1} until they reached the tower. Using a ${noun3}, they outsmarted the ${mythicalCreature} and freed the captive.\n\n` +
`With a ${adjective10} celebration, they all returned home. The end!`;
function touchStarted() {
speech.speak(madLibStory);