import ddf.minim.*; Minim minim; AudioSnippet pan, ii, aa; PFont font; int x,y; int nombre = 0; int compteur = 0; int back = 235; int cote = 5; void setup() { size(400,300); frameRate(50); background(back); cursor(CROSS); smooth(); fill(0); noStroke(); font = loadFont("ArialMT-18.vlw"); textFont(font, 18); text("tues-tu rapidement ?", 10, 20); minim = new Minim(this); pan = minim.loadSnippet("pan.mp3"); ii = minim.loadSnippet("ii.mp3"); aa = minim.loadSnippet("aa.mp3"); } void draw() { compteur++; } void stop() { pan.close(); ii.close(); aa.close(); minim.stop(); super.stop(); } void mousePressed() { if (nombre == 0) { background(back); dessinerCible(); nombre++; compteur = 0; } else { pan.play(0); if (x-cote < mouseX & mouseX < x+cote & y-cote < mouseY & mouseY < y+cote) { afficherSang(); aa.play(0); if (nombre == 10) { afficherResultat(); nombre = 0; } else { dessinerCible(); nombre++; } } else { ii.play(0); } } } void dessinerCible() { x = int(random(cote, width-cote)); y = int(random(cote, height-cote)); fill(250, 229, 36); ellipse(x, y, 2*cote, 2*cote); fill(170, 138, 31); triangle(x-15, y-2, x+15, y-2, x, y-8); stroke(0); line(x-1, y-1, x-2, y-1); line(x+1, y-1, x+2, y-1); line(x-1, y+2, x+1, y+2); noStroke(); } void afficherSang() { fill(255, 0, 0); for (int i = 0; i < 10; i++) { int tache = int(random(2*cote)); ellipse(x+int(random(-2*cote, 2*cote)), y+int(random(-2*cote, 2*cote)), tache, tache); } } void afficherResultat() { float resultat = float(compteur)/50; fill(0); text("ton resultat est de "+resultat+" sec pour 10 morts.", 10, 20); if (resultat < 8) { text("??? euh je ne savais pas que c'etait faisable", 10, 40); text("tiens moi au courant que j'affiche ta photo :-)", 10, 80); } else if (resultat < 10) { text("bravo, quelle dexterite !", 10, 40); } else if (resultat < 12) { text("bien, je vois que tu es un tueur.", 10, 40); } else if (resultat < 15) { text("pas mal, un peu plus vite ?", 10, 40); } else { text("oulala... tu as la main dans le platre ?", 10, 40); } text("rejouer ?", 10, 60); }