xxxxxxxxxx
324
let matchfound = false; //make matchfound a global variable
//////////
let x = 30,
y = 60;
let n = 3;
let n2 = 3;
let n3 = 3;
let numSentences1 = 2;
let numSentences2 = 2;
let numSentences3 = 2;
let displayText = [""];
let markov;
let markov2;
let markov3;
let sourceMoon;
let sourceMiniMoon;
let sourceBakunawa;
let moon = ["power", "instincts", "creatures"];
let miniMoon = ["love", "soul", "pain"];
let bakunawa = ["earth", "voice", "heaven"];
let inputField;
let submitButton;
var state = 0
var gif;
function preload (){
sourceMoon = loadStrings("moon.txt");
sourceMiniMoon = loadStrings("miniMoon.txt");
sourceBakunawa = loadStrings("bakunawa.txt");
story1 = loadImage("1.png");
story2 = loadImage("2.png");
story3 = loadImage("3.png");
story4 = loadImage("4.png");
story5 = loadImage("5.png");
story6 = loadImage("6.png");
story7 = loadImage("7.png");
story8 = loadImage("8.png");
story9 = loadImage("9.png");
story10 = loadImage("10.png");
arrow = loadImage("arrow.png");
gif = createImg("https://media2.giphy.com/media/v1.Y2lkPTc5MGI3NjExbDJveGtzNmRlYWlkaDB4YTk5cnRvdWVtdnUzd3Zvem50Y3BjeWMweiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9cw/c9J6sCu9HrChJUmzWs/giphy.gif", 'sparkling background');
}
function setup() {
createCanvas(444, 444);
// Create Markov models
markov = RiTa.markov(n);
markov2 = RiTa.markov(n2);
markov3 = RiTa.markov(n3);
// Load text into the models
markov.addText(sourceMoon.join(" "));
markov2.addText(sourceMiniMoon.join(" "));
markov3.addText(sourceBakunawa.join(" "));
inputField = createInput();
inputField.position(40, 300);
inputField.hide();
submitButton = createButton('offer prayer');
submitButton.position(inputField.x + inputField.width + 10, 300);
submitButton.mousePressed(checkPrayer);
submitButton.style('background-color', color(199, 255, 255));
submitButton.hide();
}
function draw() {
if(!matchfound){
let bbBlue = color(199, 255, 255);
background(17, 27, 44);
textFont('Courier New');
fill(bbBlue);
gif.position(0, 0);
gif.size(444, 444);
if (state == 0) {
screen1();
} else if (state == 1) {
screen2();
} else if (state == 2) {
screen3();
} else if (state == 3) {
screen4();
} else if (state == 4) {
screen5();
} else if (state == 5) {
screen6();
} else if (state == 6) {
screen7();
} else if (state == 7) {
screen8();
} else if (state == 8) {
screen9();
} else if (state == 9) {
screen10();
} else if (state == 10) {
screen11();
} else if (state == 11) {
screen12();
}
}
}
//Useful to have multiple elements on one screen
function screen1() {
fill(255);
textSize(13);
textStyle(NORMAL);
text('bakunawa (/baa·koo·naa·wuh/)', 115, 120);
textStyle(ITALIC);
text('"the moon-eater"', 160, 135);
image(story1, 0, 0, width, height);
textSize(12);
textStyle(NORMAL);
text('click to continue', 158, 410);
}
function screen2() {
textStyle(NORMAL);
textAlign(LEFT);
fill(255);
text(' According to Filipino mythology, the supreme \n god and creator of all things, Bathala, created \n seven moons to illuminate the earth, one for \n each night of the week.', 45, 30);
image(story2, -10, 10, width, height);
text('continue', 285, 428);
image(arrow, 40, 45, 400, 400);
}
function screen3() {
fill(255);
text(' Bakunawa, a serpent-like dragon, lived in the \n depths of the ocean. Bakunawa was amazed by these \n seven moons brightly lit against the dark sky. \n They had never seen something so illuminating! ', 40, 30);
image(story3, 12, 25, 420, 420);
text('continue', 285, 428);
image(arrow, 40, 45, 400, 400);
}
function screen4() {
image(story4, 10, 25, 430, 430);
fill(255);
text(' The moons’ radiance drove his desire to capture \n and possess them like a collection of pearls. \n Bakunawa yearned for them all. An unquenchable \n thirst.', 40, 30);
text('continue', 285, 428);
image(arrow, 40, 45, 400, 400);
}
function screen5() {
image(story5, 0, 0, width, height);
fill(255);
text(' He arose from the ocean and swallowed the moons \n one by one. Each capture resulted in eclipses, \n earthquakes, rain, and wind. ', 40, 30);
text('continue', 285, 428);
image(arrow, 40, 45, 400, 400);
}
function screen6() {
image(story6, 0, 12, width, height);
fill(255);
text(" Over time, Bakunawa successfully captured six moons. \n Leaving the last moon. To avoid eternal darkness \n and the destruction of their world, ancient Filipinos \n discovered Bakunawa's weakness -- loud noises.", 20, 30);
text('continue', 285, 428);
image(arrow, 40, 45, 400, 400);
}
function screen7() {
image(story7, 0, 20, width, height);
fill(255);
text(' The evening Bakunawa attempted to swallow the final \n moon, the Filipinos banged pots and pans and yelled \n as loud as they could. Frightened Bakunawa \n spat out the moon and crashed into the dark ocean. ', 30, 30);
text('continue', 285, 428);
image(arrow, 40, 45, 400, 400);
}
function screen8() {
image(story8, 0, 0, width, height);
fill(255);
text(' The moon returned to the skies above, illuminating \n the night once again. The Filipinos celebrated \n and Bathala smiled in pride over their victory \n of the “moon-eater.” ', 30, 30);
text('continue', 285, 428);
image(arrow, 40, 45, 400, 400);
}
function screen9() {
image(story9, 8, 0, width, height);
fill(255);
textStyle(ITALIC);
text(' Fast-forward to 2024…', 30, 30);
textStyle(NORMAL);
text(' There has been a recent discovery of a mini-moon, \n 2024 PT5, that will temporarily orbit Earth \n from September 29 to November 25.', 30, 45);
text('continue', 285, 428);
image(arrow, 40, 45, 400, 400);
}
function screen10() {
image(story10, 4, 0, width, height);
fill(255);
textSize(15);
textStyle(BOLD);
text(' Bakunawa has returned.', 40, 80);
textStyle(NORMAL);
text(' Ravenous as ever.', 40, 100);
text(' Lusting over this mini-moon.', 40, 120);
text('continue', 285, 428);
image(arrow, 40, 45, 400, 400);
}
function screen11() {
textSize(15);
fill(255);
textStyle(BOLD);
text(' The earth’s sense of balance and \n harmony are on the line and the \n night’s illumination is dependent \n upon you.', 60, 200);
}
function screen12() {
let blue = color(199, 255, 255);
background(17, 27, 44);
textFont('Courier New');
fill(199, 255, 255);
textSize(12);
fill(255);
textAlign(LEFT);
textStyle(NORMAL);
text(' Please offer a prayer to the collective using one \n of the following words:', 32, 100);
textSize(24);
fill(199, 255, 255);
text('Love Pain Power', 40, 170);
text('Heaven Earth Creatures', 40, 210);
text('Instincts Soul Voice', 40, 250);
inputField.show();
submitButton.show();
}
function checkPrayer() {
ellipse(100,100,100,100)
background(17, 27, 44);
fill(255);
textSize(14);
let prayer = inputField.value().toLowerCase().split(/\s+/);
for (let word of prayer) {
if (moon.includes(word)) {
background(17, 27, 44);
textStyle(ITALIC);
text("A message from the Moon:", 30, 40);
tint(255, 160);
image(story8, 0, 40, width, height);
textStyle(NORMAL);
displayText = markov.generate(numSentences3);
text(displayText.join(" "), x, y, 390, 420);
matchfound = true;
inputField.hide();
submitButton.hide();
break;
} else if (miniMoon.includes(word)) {
background(17, 27, 44);
textStyle(ITALIC);
text("A message from the Mini-Moon:", 30, 40);
tint(255, 160);
image(story9, 0, 35, width, height);
textStyle(NORMAL);
displayText = markov2.generate(numSentences2);
text(displayText.join(" "), x, y, 390, 420);
matchfound = true;
inputField.hide();
submitButton.hide();
break;
} else if (bakunawa.includes(word)) {
background(17, 27, 44);
textStyle(ITALIC);
text("A message from Bakunawa:", 30, 40);
tint(255, 160);
image(story10, 0, 0, width, height);
textStyle(NORMAL);
displayText = markov3.generate(numSentences1);
text(displayText.join(" "), x, y, 390, 420);
matchfound = true;
inputField.hide();
submitButton.hide();
break;
}
}
if (!matchfound) {
textSize(12);
textStyle(NORMAL);
text(' Please offer a prayer to the collective using one \n of the following words:', 32, 100);
textSize(24);
fill(199, 255, 255);
text('Love Pain Power', 40, 170);
text('Heaven Earth Creatures', 40, 210);
text('Instincts Soul Voice', 40, 250);
textSize(12);
textStyle(ITALIC);
fill(255);
text('Please offer a prayer using one of the words.', 40, 290);
// console.log("no match");
}
}
function mousePressed(){
if (state < 11) {
state++;
}
}