xxxxxxxxxx
119
let fond;
let ratio = 4961/3508;
let formatL = 500;
let formatH = formatL*ratio;
let tableau_etoile = [];
let tableau_crane = [];
let tableau_note = [];
let crane_gauche;
let crane_droit;
let sourire;
let sound;
let bouge = false;
let lance = false;
let tableau_particule_bas = [];
let nb_particules = 300;
let nb_notes = 50;
function setup() {
createCanvas(formatL, formatH);
fond = loadImage("Assets/Images/Ernesto_delaCruz.jpg");
crane_gauche = loadImage("Assets/Images/petit_crane_gauche.png");
crane_droit = loadImage("Assets/Images/petit_crane_droite.png");
sound = loadSound("Assets/Sounds/recuérdame.MP3");
sourire = loadImage("Assets/Images/sourire.png");
star = loadImage("Assets/Images/etoiles.png");
tableau_etoile[0] = new Etoile(320, 80, 50, 50, star);
tableau_etoile[1] = new Etoile(317, 159, 30, 30, star);
tableau_etoile[2] = new Etoile(315, 247, 20, 20, star);
tableau_etoile[3] = new Etoile(377, 309, 20, 20, star);
tableau_etoile[4] = new Etoile(410, 487, 40, 40, star);
tableau_etoile[5] = new Etoile(390, 593, 50, 50, star);
tableau_crane[0]= new Crane(3, 1, 50, 50, crane_gauche);
tableau_crane[1] = new Crane(3, formatH-50, 50, 50, crane_gauche);
tableau_crane[2] = new Crane(formatL-50, 1, 50, 50, crane_droit);
tableau_crane[3] = new Crane(formatL-50, formatH-50, 50, 50, crane_droit);
for (let i = 0; i < nb_notes; i = i +1){
tableau_note[i] = new Note();
}
}
function draw() {
image(fond, 0, 0, formatL, formatH);
for (let i = 0; i < 6; i = i + 1) {
tableau_etoile[i].dessiner();
}
for (let i = 0; i < 4; i = i + 1) {
tableau_crane[i].dessiner();
}
if (
mouseX > 270 &&
mouseX < 330 &&
mouseY > 412 &&
mouseY < 482 &&
mouseIsPressed
) {
sound.play();
}
// Lancer des pétales
if (keyIsPressed && keyCode == 69) {
for (let i = 0; i < nb_particules; i = i + 1) {
tableau_particule_bas[i] = new Particule(formatH);
}
lance = true;
}
if (lance === true) {
for (let i = 0; i < nb_particules; i = i + 1) {
tableau_particule_bas[i].dessiner();
tableau_particule_bas[i].lancer();
}
}
// Musique est jouée
if (sound.isPlaying()) {
bouge = true;
for (let i = 0; i < nb_notes; i = i + 1) {
tableau_note[i].dessiner();
tableau_note[i].deplacer();
}}
if (bouge === true) {
for (let i = 0; i < 6; i = i + 1) {
tableau_etoile[i].bouger();
}
for (let i = 0; i < 4; i = i + 1) {
tableau_crane[i].bouger();
}
image(sourire, 130, 310, 20, 20);
}
//Musique pas jouée
if (sound.isPlaying() === false) {
bouge = false;
}
}