Voilà j'ai essayer de raccourcir mon code au maximum et j'ai laissé la partie qui me pose problème.
var histoire="Résumé";
var ListeSuspects="Liste des suspects :\n\n -Ex-compagne\n\n -Son voisin\n\n -Sa petite soeur\n\n -Son meilleur ami\n\n -son collègue";
var entréeUtilisateur;
var suspect;
var mere;
var descendre=0;
var PositionY=272;
var LirePapier=false;
var afficheScene1 = true;
var X = 200;
var mousePressed;
let timer = 200;
function preload() {
imageDuSalon = loadImage ("salon.png");
FondEcran = loadImage ("FondEcran.png");
}
function setup() {
createCanvas(windowWidth, windowHeight);
}
function draw() {
//afficher la scène principale
if (afficheScene1 == true) {
scene1();
}
if (afficheScene1 == false){
sceneMail();
}
//afficher la scène quand on clique sur les lumières
if (mouseIsPressed && dist(mouseX, mouseY, 823, 144) < 60|| mouseIsPressed && dist(mouseX, mouseY, 814, 77) < 60) {
scene2(); }
}
//Scène qui s'affiche quand on clique sur les lumière
function scene2() {
createCanvas(windowWidth, windowHeight);
background(0, 0, 0);
//message au centre
textAlign(CENTER);
textSize(20);
text("Oh non!\n\n Ah, mais quelle est cette chose qui brille? ", windowWidth / 2, windowHeight / 2);
//Création de la bague
fill(random(240, 258), random(240, 255), random(0, 100));
noStroke();
ellipse(X, 500, 10, 10);
fill(0,0,0);
ellipse(X, 500, 5, 5);
//Création du message de la bague
fill(255,255,255);
rect(120, 450 , 180, 40);
textSize(14);
fill(0,0,0);
text("On dirait bien une \nbague de fiançaille", 205,465);
if (dist(mouseX, mouseY, 200, 100) < 5 ) {
scene1();
}
}
//Scène principale de l'écran d'acceuil
function scene1() {
print('scene1');
//Fond principal
background(155,212,176);
image(imageDuSalon, windowHeight/2, 0);
//récit de l'histoire avec fond et suspects
fill(142, 210, 160);
rect(5, 90, 316, 280);
fill(142, 210, 160);
rect(5, 380, 316, 150);
fill(255, 255,255);
textSize(18);
textAlign(LEFT);
textFont('Courier New');
text(histoire, 5, 10, 316, 455);
textLeading(10);
text(ListeSuspects, 42,450);
//exécuter les fonctions des indices
Ordinateur();
print(mouseX);
print(mouseY);
}
function Ordinateur() {
//emmène vers une autre page quand on clique sur l'ordinateur
if(mouseIsPressed && mouseX>370 && mouseX<427 && mouseY>334 && mouseY<367)
{ afficheScene1 = false;
}
}
}
//ORDINATEUR
var NouveauMessage = 'Vous avez reçu un nouvel email de : ';
var Mail = ''
var compteur = 0;
var AfficherMail=true;
function sceneMail() {
createCanvas(windowWidth, windowHeight);
background(FondEcran);
Notification();
}
function Notification() {
fill(16, 52, 166);
rect(windowWidth / 2 - 100, windowHeight / 2, 150, 50);
fill(255, 255, 255);
textSize(30);
text('OK', windowWidth / 2 - 50, windowHeight / 2 + 35);
mySound.play();
fill(119, 181, 254);
rect(windowWidth / 2 - 150, windowHeight / 2 - 100, 250, 100);
fill(0, 0, 0);
textSize(20);
text(NouveauMessage, windowWidth / 2 - 130, windowHeight / 2 - 90, 220, 80);
textFont('Courier New');
textLeading(5);
noLoop();
}
function Email() {
if (AfficherMail==true){
fill(119, 181, 254);
rect(windowWidth/2-254,windowHeight/2-200,450,350);
fill(0, 0, 0);
textSize(20);
text(Mail,windowWidth/2-150,windowHeight/2-100, 220, 80);
textFont('Courier New');
textLeading(5);
fill(16, 52, 166);
rect(windowWidth / 2 - 100, windowHeight / 2+100, 150, 50);
fill(255, 255, 255);
textSize(30);
text('OK', windowWidth / 2 - 50, windowHeight / 2 + 135);
}
}
function mouseClicked() {
var CliquerSurOk1 = mouseX > windowWidth / 2 - 100 && mouseX < windowWidth / 2 + 50 && mouseY > windowHeight / 2 && mouseY < windowHeight / 2 + 70
CliquerSurOk1 =true;
var CliquerSurOk2 = mouseX > windowWidth / 2 - 100 && mouseX < windowWidth / 2 + 50 && mouseY > windowHeight / 2+100 && mouseY < windowHeight / 2 + 205
if (CliquerSurOk1==true && compteur==0) {
Email();
}
if(CliquerSurOk2){
compteur=1
}
if (CliquerSurOk2 && compteur==1) {
AfficherMail=false;
afficherScene1=true;
}
}
EDIT : Correction des balises de code