xxxxxxxxxx
129
let ScreenOn;
let Question = 0;
let Answered = 1;
let Secret = 2;
let mangoFade;
let fadeAmount = 0.5;
let isPlaying = false;
let noButtonX, noButtonY; // Position for the "Nu! >:(" button
let yesButtonX, yesButtonY; // Position for the "Yes :3" button
function preload() {
soundFormats('mp3');
sed = loadSound("sed.mp3");
fir = loadImage("first.gif");
sec = loadImage("second.gif");
mango = loadImage("mango.png")
}
function setup() {
createCanvas(600, 600);
textAlign(CENTER);
imageMode(CENTER);
textFont("Comic Sans MS", 25);
ScreenOn = Question;
// Initialize button positions
noButtonX = 2.25 * width / 4;
noButtonY = height / 1.4;
yesButtonX = width / 4;
yesButtonY = height / 1.4;
mangoFade = 0;
// Adjust gif sizes
fir.resize(fir.width/2, fir.height/2);
}
function button(title, button_color, x, y, w, h, rounding, text_size, isNoButton = false) {
// If hovered over this button
if(mouseX > x && mouseX < x+w && mouseY > y && mouseY < y+h) {
// If it's no, then we have to reposition the button
if(isNoButton) {
button_color = color('rgb(238,127,127)');
noButtonX = random(0, width - w); // Ensure the button stays within canvas
noButtonY = random(0, height - h);
}
// If it's yes, then we change the hover colour and switch screens
if(!isNoButton) {
//change color
button_color = color('rgb(109,228,131)');
// If clicked, then we change the screen
if(mouseIsPressed) {
ScreenOn = Answered;
}
}
//Secret button
if(title == "Shh Secret...") {
if(mouseIsPressed) {
ScreenOn = Secret;
}
}
}
//Drawing the button:
strokeWeight(0);
fill(button_color);
rect(x, y, w, h, rounding);
//Button text:
fill(255);
textSize(text_size);
text(title, (x+(x+w))/2, ((y+(y+h))+15)/2);
}
function QuestionStage() {
image(fir, width/2, 150);
fill(0);
text("Hi my Aiishu Pie <3", width/2, height/2);
text("Will you be my valentine?", width/2, height/1.7);
// Draw buttons using the dynamically updated positions
button("Yes :3", color('rgb(34, 197, 64)'), yesButtonX, yesButtonY, 100, 40, 4, 25, false);
button("Nu! >:(", color('rgb(238, 69, 69)'), noButtonX, noButtonY, 100, 40, 4, 25, true);
fill(0);
text("~ From Mr. Baday", width/2, height/1.1);
}
function AnsweredStage() {
image(sec, width/2, 150);
fill(0);
textSize(25);
text("YAYAYAYAYAYAYAYAYA", width/2, height/1.8);
text("WOOOOOOOOOOOO!!!!", width/2, height/1.6);
text("I LOVE YOU BIG HUGS AND KISSES!! <3", width/2, height/1.45);
button("Shh Secret...", color('rgb(231,167,167)'), 20, height-50, 90, 20, 4, 13, false);
}
function SecretStage() {
sed.setVolume(1);
if(!isPlaying) {
sed.play();
isPlaying = true;
}
fill(255, 0, 0, mangoFade);
image(mango, width/2, 250);
text("Mango is sed because no hugs :(", width/2, height/1.2);
text("Give mango hugs and kisses", width/2, height/1.1);
mangoFade += fadeAmount;
}
function draw() {
background(252, 230, 230);
textSize(32);
if(ScreenOn == Question) {QuestionStage(); }
else if(ScreenOn == Answered) {AnsweredStage(); }
else if(ScreenOn == Secret) {SecretStage(); }
}