xxxxxxxxxx
68
let wlcm = ['WELCOME', 'TO', 'MACBETH'];
let para = ['Soldier, and loyal to a fault to his king.', ' Yet, when the witches prophesied him –currently the Thane of Glamis, to become Thane of Cawdor, then, king he cannot help to indulge.', ' After all, a man is bought by greed, nothing could tame Macbeth — not even his own self.',' In the journey to usurp the throne, he and his wife are driven mad, and experiences a series of hallucinations.',' You must guide them through their hallucinations, so that they can complete their job. '];
let instruction = ['If you are strong enough, then click the mouse.'];
let prophecy, intro;
let titleIndex = 0;
let frameCounter = 0;
let paraIndex = 0;
let linecnt = 0;
let paraframeCounter = 0;
function preload() {
soundFormats('mp3', 'ogg');
prophecy = loadSound('/assets/prophecy.mp3');
intro = loadSound('/assets/intro.mp3');
}
function menuSetup() {
createCanvas(800, 600); // Adjust size as needed
prophecy.onended(playIntro);
prophecy.play();
}
function playIntro() {
intro.play();
}
function menuDraw() {
background('black');
textFont('LATO');
fill('white');
// Animate title
textSize(32);
textAlign(CENTER, TOP);
text(wlcm[titleIndex], width/2, 40);
// Change title every 60 frames (1 second at 60 fps)
frameCounter++;
if (frameCounter >= 20) {
titleIndex = (titleIndex + 1) % wlcm.length;
frameCounter = 0;
}
// Draw paragraph
textSize(16);
textAlign(CENTER, TOP);
text(instruction[0], width / 2, height - 100);
text(para[0], 50, height/2 - 100, width - 100);
paraframeCounter++;
if (paraframeCounter >= 10){
paraIndex = (paraIndex + 1) % para.length;
paraframeCounter = 0;
textSize(25);
}
}
function draw() {
menuDraw();
}