diff --git a/build/boucle_de_jeu/boucle_de_jeu.pde b/build/boucle_de_jeu/boucle_de_jeu.pde index 101b04be761618f28f631918cd603e479ebcd201..4674e5014db217f39b7c97a40d618038607f4742 100644 --- a/build/boucle_de_jeu/boucle_de_jeu.pde +++ b/build/boucle_de_jeu/boucle_de_jeu.pde @@ -15,7 +15,7 @@ float ax, ay, az; SoundFile droite1, droite2, droite3, gauche1, gauche2, gauche3, neutre1, neutre2, neutre3; SoundFile epee1, epee2, epee3, woosh, clang1, clang2, clang3; SoundFile cri1, cri2; -SoundFile bgMusic, mort, aie; +SoundFile bgMusic, battle, mort, aie, gameover; KalmanFilter kf = new KalmanFilter(); float timer; float cooldown_listener; @@ -29,6 +29,7 @@ float init_cooldown; float reaction; float init_reaction; int ennemy_move; //0 : droite, 1 : gauche, 2 : neutre. +boolean gameoverhasplayed; float comp; float lastcomp; float a; @@ -78,6 +79,7 @@ void setup() { score = 0; combo = 0; ennemy_move = -1; + gameoverhasplayed = false; comp = 0; lastcomp = 0; @@ -94,7 +96,7 @@ void setup() { //sons bgMusic = new SoundFile(this, "bgmusic.wav"); - bgMusic.loop(); + battle = new SoundFile(this, "battle.mp3"); droite1 = new SoundFile(this, "droite1.wav"); droite2 = new SoundFile(this, "droite2.wav"); droite3 = new SoundFile(this, "droite3.wav"); @@ -115,6 +117,7 @@ void setup() { mort = new SoundFile(this, "mort.wav"); cri1 = new SoundFile(this, "cri.mp3"); cri2 = new SoundFile(this, "rale.wav"); + gameover = new SoundFile(this, "gameover.mp3"); instructions = new SoundFile(this, "instructions.wav"); textFont(createFont("SansSerif", 30 * displayDensity)); @@ -156,6 +159,10 @@ void fade(int n){ void draw() { switch(mode){ case 0 : //Correspond au menu de jeu + gameoverhasplayed = false; + if (!bgMusic.isPlaying()){ + bgMusic.play(); + } vie = 3; stroke(0); fill(startColor); @@ -167,6 +174,12 @@ void draw() { text("Instructions", startX+startSizeX/50, startY+startSizeY/3, startSizeX, startSizeY); break; case 1 : //Correspond au jeu en lui-même + if (bgMusic.isPlaying()){ + bgMusic.stop(); + } + if (!battle.isPlaying()){ + battle.play(); + } if (vie == 3){ image(troiscoeur, 0, 0, displayWidth, troiscoeur.height * (displayWidth/troiscoeur.width)); } @@ -327,6 +340,8 @@ void draw() { if (vie > 0) aie.play(); //animation sur les coeurs if (vie <= 0){ + battle.stop(); + mort.play(); mode = 2; background(mortImage); } @@ -339,17 +354,21 @@ void draw() { break; case 2 : //Correspond à la mort du joueur - textFont(font); - fill(245,24,1); - text("Game Over",displayWidth/4.3,displayHeight/2); - fill(255,255,255,100); - rect(startX, startY, startSizeX, startSizeY); - fill(255,255,255,100); - rect(startX-displayWidth/20, startY2, startSizeX+displayWidth/10, startSizeY); - fill(0,0,0,100); - text("Retour menu", startX+startSizeX/20, startY+startSizeY/3, startSizeX, startSizeY); - text("Combo max : " + max_combo + "\nScore : " + score, startX, startY2+startSizeY/6, startSizeX+displayWidth/10, startSizeY); - break; + if (!gameoverhasplayed){ + gameoverhasplayed = true; + gameover.play(); + } + textFont(font); + fill(245,24,1); + text("Game Over",displayWidth/4.3,displayHeight/2); + fill(255,255,255,100); + rect(startX, startY, startSizeX, startSizeY); + fill(255,255,255,100); + rect(startX-displayWidth/20, startY2, startSizeX+displayWidth/10, startSizeY); + fill(0,0,0,100); + text("Retour menu", startX+startSizeX/20, startY+startSizeY/3, startSizeX, startSizeY); + text("Combo max : " + max_combo + "\nScore : " + score, startX, startY2+startSizeY/6, startSizeX+displayWidth/10, startSizeY); + break; } }