
axelle et elise
int passedtime;//pour gérer le compte à rebours
boolean stoptime=true;//pour gérer le compte à rebours
int score=0;
int a=0;// affectation d'une valeur aux variables a,b,x,y (rectangle réponse 1)
int b=0;
int mywidth = 1920;
int myheight = 1080;
int page=0;
int xspectre1;//=0;
int yspectre1;//=100;
int xspectre2;//=0;
int yspectre2;//=100;
int xspectre3;//=0;
int yspectre3;//=100;
PImage img;
PImage img2;
PImage img3;
PImage img4;
PImage imgspectre1;
PImage imgspectre2;
PImage imgspectre3;
PImage imgdiffractionschema;
PImage imgformule1;
PImage imgetat;
boolean valider=false;//verifier le clic sur "valider" question 5
boolean v=false;
int [] vitesseX;
int [] vitesseY;
int [] x;
int [] y;
String pseudo;
int delay=0;
int date=0;
int oldDate=0;
import ddf.minim.*;
import ddf.minim.signals.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
Minim minim;
AudioPlayer yeah;
AudioPlayer yeah2;
AudioPlayer yeah3;
AudioPlayer yeah4;
AudioPlayer yeah5;
AudioPlayer dring;
AudioPlayer cri;
AudioPlayer cri2;
AudioPlayer cri3;
AudioPlayer cri4;
AudioPlayer cri5;
void setup() {
frameRate(12);
background(#00FFCE);
img = loadImage("debut.jpg");//image page d'accueil
img2 = loadImage ("carbone.png");//réponse 2
img3 = loadImage("laser.jpg");//question 3
img4=loadImage("spectreelec.png");//réponse 5
imgetat= loadImage("etat.jpg");
x=new int [10];//balles question 4
y=new int [10];
vitesseX=new int [10];
vitesseY=new int [10];
for (int i=0;i<10;i++) {
x[i]=(int)random(40, 460);
y[i]=(int)random(40, 460);
vitesseX[i]=(int)random(2, 6);
vitesseY[i]=(int)random(2, 5);
}
size(mywidth, myheight);
minim=new Minim(this);
yeah= minim.loadFile("yeaaah.mp3");//son acclamation
yeah2= minim.loadFile("yeaaah2.mp3");
yeah3= minim.loadFile("yeaaah3.mp3");
yeah4= minim.loadFile("yeaaah4.mp3");
yeah5= minim.loadFile("yeaaah5.mp3");
dring=minim.loadFile("dring.mp3");
cri=minim.loadFile("cri.mp3");
cri2=minim.loadFile("cri2.mp3");
cri3=minim.loadFile("cri3.mp3");
cri4=minim.loadFile("cri4.mp3");
cri5=minim.loadFile("cri5.mp3");
pseudo=new Dialog().readString("Quel est votre pseudo?");//boite de dialogue
//println(width);
//println(height);
imgspectre1 = loadImage ("spectre1.png");//question 5
imgspectre2 = loadImage ("spectre2.png");
imgspectre3 = loadImage ("spectre3.png");
xspectre1=width/5;
xspectre2=width/3-50;
xspectre3=width/2-50;
yspectre1=100;
yspectre2=100;
yspectre3=100;
imgdiffractionschema=loadImage("diffractionschema.jpg");
imgformule1=loadImage("formule1.png");
}
void draw() {
if (page==0) {
page0();
}
if(page==45){
page45();
}
if (page==1) {
page1();
}
if (page==2) {
page2();
}
if (page==3) {
page3 ();
}
if (page==4){
page4 ();
}
if (page==5){
page5 ();
}
if (page==6){
page6 ();
}
if (page==7){
page7 ();
}
if (page==8){
page8 ();
}
if (page==9){
page9 ();
}
if (page==10){
page10 ();
}
if (page==11){
page11 ();
}
println(score);
println(millis());
}
void stop (){
yeah.close();
yeah2.close();
yeah3.close();
yeah4.close();
yeah5.close();
dring.close();
cri.close();
cri2.close();
cri3.close();
cri4.close();
cri5.close();
minim.stop();
super.stop();
}
void page0 () {
image(img, 0, 0, width, height);
fill(#FFFFFF);
textSize (100);
text("Start ", width/2-117, height/2+20);
textSize(20);
fill(#03E8FF);
if (mouseX<width-width/3) {
if (mouseY<height-height/3) {
if (mouseX>width/3) {
if (mouseY>height/3) {
cursor(HAND);
if (mousePressed) {
page=45;
background(#00FFCE);
frameRate (30);
if(stoptime==true){
passedtime=millis();
stoptime=false;
}
}
}
}
}
}
}
void page45 () {
background(#FC3B8F);
textSize(100);
cursor(WAIT);
fill(#FFFFFF);
text("Bonjour "+pseudo+"!",width/3,height/3-200);
text("Le jeu va commencer!",width/5+60,height/3-100);
textSize(200);
int time=millis()-passedtime;
if (time<=1000){
fill(#0700FF);
text("3",width/2,height/2);
}else if(time<=2000){
fill(#42E523);
text("2",width/2,height/2);
}else if(time<=3000){
fill(#FAC0FA);
text("1",width/2,height/2);
}else if(time<=4000){
dring.play();
text("GO!",width/2-150,height/2);
}else if(time>5000){
cursor(HAND);
page=1;
background(#00FFCE);
}
}
void page1 () {
frameRate(10);
fill(#0017FF); //couleur//
textSize (50);
text(" Un diastéréoisomère est l'image d'une molécule non superposable", width/2-820, height/5); //afficher la question
text(" à celle-ci", width/2-90, height/5+70);
fill(#FAF200);// couleur de remplissage pour les rectangles//
stroke(#FF038A);
rect(width/2-215, height/2-50, 40, 40);//deux rectangles l'un en dessous de l'autre//
rect(width/2-215, height/2+50, 40, 40);
fill(#0017FF);
text("vrai", width/2-150, height/2-15);//deux réponses//
text("faux", width/2-150, height/2+85);
//text("score="+score,600,150);
if (mouseX<width/2-175) {
if (mouseX>width/2-215) {
if (mouseY>height/2-50) {
if (mouseY<height/2-10) {
cursor(HAND);
if (mousePressed) {//vérifie si la souris clique dans le bon rectangle//
textSize (100);//choix de la police//
fill(#FF038A);//choix de la couleur//
text("Perdu...", width-width/3, height/2);//texte qui réprimande//
cri.play();
textSize (40);
fill(#FAF200);
text("suivant", width-150, height-150);
frameRate(10);
score=score+0;
}
}
}
}
}
if (mouseX<width/2-175) {
if (mouseX>width/2-215) {
if (mouseY>height/2+50) {
if (mouseY<height/2+90) {
cursor(HAND);
if (mousePressed) {
date=millis();
delay=millis()-oldDate;
println(delay);
if (delay>1000) {
score=score+1;
oldDate=millis();
}
textSize(100);//choix de la police//
fill(#FF038A);
text("Bravo !!", width-width/3,height/2);//texte qui félicite//
textSize (40);
fill(#FAF200);
text("suivant", width-150, height-150);
yeah.play();
}
}
}
}
}
if (mouseX<width) {
if (mouseX>width-300) {
if (mouseY<height) {
if (mouseY>height-300) {
cursor(HAND);
if (mousePressed) {
//score = score+1;
page = 2;
}
}
}
}
}
}
void page2() {
background(#4300FF);
frameRate (60);
fill(#009FFF);
rect(a, b, width/2+100, height/2);
a=a+2;
b=b+2;
if (a>width/5) {
if (b>height/4) {
a=a-2;
b=b-2;
fill(#009FFF);
textSize (150);
text("REPONSE", width/7 , height/5);
fill(#FFE203);
textSize(45);
text("Deux énantiomères sont des molécules images ", a+15, b+100);
text("l'une de l'autre dans un miroir mais ", a+120, b+150);
text("non superposables", a+300, b+200);
text("Deux diastéréoisomères sont des molécules ", a+45, b+300);
text("qui ne sont ni superposables, ni images", a+114, b+350);
text("l'une de l'autre dans un miroir", a+220, b+400);
ellipse(width/2+750, height/2-400, width/6, height/6);
textSize(50);
fill(#009FFF);
text("Suivant", width/2+660, height/2-385);
if (mouseX>(width/2+750)-width/6) {
if (mouseX<width/2+750+width/6) {
if (mouseY>(height/2-400)-height/6) {
if (mouseY<(height/2-400)+height/6) {
if (mousePressed) {
page = 3 ;
background(#FFF536);
}
}
}
}
}
}
}
}
void page3 (){
fill(#FF038A); //couleur//
frameRate (12);
textSize (60);
text(" Qu'est ce qu'un carbone asymétrique ?", width/2-820, height/5); //afficher la question
fill(#FF038A);//couleur de remplissage pour les rectangles//
stroke (#00FFCE);
rect(width/2-800, height/2-50, 40, 40);//quatre rectangles l'un en dessous de l'autre et à côté//
rect(width/2-800, height/2+150, 40, 40);
rect(width/2+50, height/2-50, 40, 40);
rect(width/2+50, height/2+150, 40, 40);
fill(#0017FF); //couleur//
textSize(35);
text("Un carbone relié à 3 autres carbones", width/2-750, height/2-20);//quatre réponses//
text("Un carbone qui a cédé un proton", width/2-750,height/2+180);
text("Un carbone ayant quatre substituants différents", width/2+100, height/2-20);
text("Un atome au sein d'une solution acide", width/2+100, height/2+180);
if (mouseX<width/2-760) {
if (mouseX>width/2 -800) {
if (mouseY>height/2-50) {
if (mouseY<height/2-10) {
cursor(HAND);
if (mousePressed) {//vérifie si la souris clique dans le bon rectangle//
textSize(100);//choix de la police//
fill(#00FFCE);
text("Perdu...", width-width/3,height/3);//texte qui félicite//
cri2.play();
textSize (40);
fill(#FF038A);
text("suivant", width-150, height-150);
}
}
}
}
}
if (mouseX<width-760) {
if (mouseX>width/2-800) {
if (mouseY>height/2+150) {
if (mouseY<height/2+190) {
cursor(HAND);
if (mousePressed) {//vérifie si la souris clique dans le bon rectangle//
textSize(100);//choix de la police//
fill(#00FFCE);
text("Perdu...", width-width/3,height/3);//texte qui félicite//
cri2.play();
textSize (40);
fill(#FF038A);
text("suivant", width-150, height-150);
}
}
}
}
}
if (mouseX<width/2+90) {
if (mouseX>width/2+50) {
if (mouseY>height/2+150) {
if (mouseY<height/2+190) {
cursor(HAND);
if (mousePressed) {//vérifie si la souris clique dans le bon rectangle//
textSize(100);//choix de la police//
fill(#00FFCE);
text("Perdu...", width-width/3,height/3);//texte qui félicite//
cri2.play();
textSize (40);
fill(#FF038A);
text("suivant", width-150, height-150);
}
}
}
}
}
if (mouseX<width/2+90) {
if (mouseX>width/2+50) {
if (mouseY>height/2-50) {
if (mouseY<height/2-10) {
cursor(HAND);
if (mousePressed) {
date=millis();
delay=millis()-oldDate;
println(delay);
if (delay>1000) {
score=score+1 ;
oldDate=millis();
}
textSize(100);
fill(#00FFCE);
text("Bravo!!", width-width/3,height/3); //texte qui félicite//
textSize (40);
fill(#FF038A);
text("suivant", width-150, height-150);
frameRate(10);
yeah2.play();
}
}
}
}
}
if (mouseX<width) {
if (mouseX>width-300) {
if (mouseY<height) {
if (mouseY>height-300)
cursor(HAND);
if (mousePressed) {
//score = score+1;
page = 4;
}
}
}
}
}
}
void page4 () {
background(#0700FF);
fill(#FF038A);
textSize (150);
text("REPONSE", width/7 , height/5);
image(img2, width/12, height/6 + 220, 219, 230);
fill(#FFE203);
textSize(45);
text("Un carbone asymétrique possède quatre substituants différents ", width/12+ 300 , height/6 + 300);
text("On retrouve parfois une étoile au dessus de ce dernier", width/12+ 300 , height/6 + 350);
ellipse(width/2+750, height/2-400, width/6, height/6);
textSize(50);
fill(#009FFF);
text("Suivant", width/2+660, height/2-385);
if (mouseX>(width/2+750)-width/6) {
if (mouseX<width/2+750+width/6) {
if (mouseY>(height/2-400)-height/6) {
if (mouseY<(height/2-400)+height/6) {
if (mousePressed) {
page = 5 ;
background(#C40A4B);
}
}
}
}
}
}
void page5 () {
image (img3, width/4, 50, width/2, 100);//mise en place de l'image appelée "img2"//
textSize(60); //taille du texte//
fill(#0017FF); //couleur texte//
text("Comment s'appelle cette figure? Une figure....", width/7, height/4); //question//
fill(#FFFFFF); //couleur rectangle//
rect(width/8, height/3, 350, 150); //huit rectangles //
rect(width/8, height/2+150, 350, 150);
rect(width/8+360, height/3, 350, 150);
rect(width/8+360, height/2+150, 350, 150);
rect(width/8+720, height/3, 350, 150);
rect(width/8+720, height/2+150, 350, 150);
rect(width/8+1080, height/3, 350, 150);
rect(width/8+1080, height/2+150, 350, 150);
fill(#000000);
textSize(45);
text("de refraction", width/8+40, height/3+70); //huit réponses dans les huit rectangles//
text("de reflexion", width/8+40, height/2+225);
text("de dilatation", width/8+390, height/3+70);
text("de diffraction", width/8+390, height/2+225);
text("de distraction", width/8+740, height/3+70);
text("d'abstention", width/8+740, height/2+225);
text("d'abolition", width/8+1100, height/3+70);
text("d'abomination", width/8+1100, height/2+225);
if ((mouseX>width/8+360)&& (mouseX<width/8+710)&&(mouseY>height/2+150)&&(mouseY<height/2+300)) {
cursor(HAND);
if (mousePressed) {//vérifie si la souris clique dans le bon rectangle//
date=millis();
delay=millis()-oldDate;
println(delay);
if (delay>1000) {
score=score+1;
oldDate=millis();
}
textSize(100);//choix de la police//
fill(#FAF200);
text("Bravo !!", width-width/3, height/2+120);//texte qui félicite//
textSize (40);
fill(#FAF200);
text("suivant", width-150, height-150);
yeah3.play();
frameRate(10);
}
}
else if ((mousePressed)&&(width/8<mouseX)&&(mouseX<width/8+1430)&&(height/3<mouseY)&&(mouseY<height/3+150)) {
textSize (100);//choix de la police//
fill(#FAF200);//choix de la couleur//
text("Perdu...", width-width/3, height/2+120);//texte qui réprimande//
cri3.play();
textSize (40);
fill(#FAF200);
text("suivant", width-150, height-150);
}
else if ((mousePressed)&&(width/8<mouseX)&&(mouseX<width/8+1430)&&(height/2+150<mouseY)&&(mouseY<height/2+300)) {
textSize (100);//choix de la police//
fill(#FAF200);//choix de la couleur//
text("Perdu...", width-width/3, height/2+120);//texte qui réprimande//
cri3.play();
textSize (40);
fill(#FAF200);
text("suivant", width-150, height-150);
}
if (mouseX<width) {
if (mouseX>width-300) {
if (mouseY<height) {
if (mouseY>height-300) {
cursor(HAND);
if (mousePressed) {
page = 6;
background(#00FFCE);
}
}
}
}
}
}
void page6 () {
fill(#009FFF);
textSize (150);
text("REPONSE", width/7 , height/5);
fill(#FA1766);
textSize(42);
text("La diffraction est un phénomène d'autant plus visible que l'ouverture a est petite",80,height/4+100);
image(imgdiffractionschema,width/6-100,height/2-100, 600,400);
image(imgformule1,width/2+150,height/2, 500, 300);
fill(#FAF200);
ellipse(width/2+750, height/2-400, width/6, height/6);
textSize(50);
fill(#009FFF);
stroke(#FF039A);
text("Suivant", width/2+660, height/2-385);
if (mouseX>(width/2+750)-width/6) {
if (mouseX<width/2+750+width/6) {
if (mouseY>(height/2-400)-height/6) {
if (mouseY<(height/2-400)+height/6) {
if (mousePressed) {
page = 7 ;
background(#FAF200);
}
}
}
}
}
}
void page7() {
background(#FAF200);
frameRate (60);
for (int i=0;i<10;i++) {
fill(#FF039A);
ellipse(x[i], y[i], 30, 30);
x[i]=vitesseX[i]+x[i];
y[i]=vitesseY[i]+y[i];
if (x[i]>470) {
vitesseX[i] =-vitesseX[i];
}
if (y[i]>470) {
vitesseY[i]=-vitesseY[i];
}
if (x[i]<30) {
vitesseX[i] =-vitesseX[i];
}
if (y[i]<30) {
vitesseY[i] =-vitesseY[i];
}
}
textSize(50); //taille du texte//
fill(#FF039A); //couleur texte//
text("Quel état de la matière nous est présenté dans cette animation ?", width/3-50, height/4);
text("Répondez à l'aide de votre clavier", width/3, height/4+60);
textSize(60);
text("1- Gazeux", width/2+100, height/2-20);
text("2- Liquide", width/2+100, height/2+180);
if(key=='1'){
textSize(100);//choix de la police//
fill(#17FCEB);
text("Bravo !!", width-width/4,height/2);//texte qui félicite//
yeah5.play();
textSize (40);
fill(#17FCEB);
text("suivant", width-150, height-150);
if(keyPressed){
date=millis();
delay=millis()-oldDate;
println(delay);
if (delay>1000) {
score=score+1;
oldDate=millis();
}
frameRate(60);
}
}else if(key=='2'){
textSize (100);//choix de la police//
fill(#17FCEB);//choix de la couleur//
text("Perdu...", width-width/4, height/2);//texte qui réprimande//
cri4.play();
textSize (40);
fill(#17FCEB);
text("suivant", width-150, height-150);
}
if (mouseX<width) {
if (mouseX>width-300) {
if (mouseY<height) {
if (mouseY>height-300) {
cursor(HAND);
if (mousePressed) {
page = 8;
background(#00FFCE);
}
}
}
}
}
}
void page8 () {
fill(#009FFF);
textSize (150);
text("REPONSE", width/7 , height/5);
fill(#FA1766);
textSize(42);
text("A l'état gazeux, les molécules se déplacent librement",100,height/4+100);
text("A l'état liquide, elles sont mobiles et entassées les unes sur les autres ",100,height/4+150);
image(imgetat,800, 500,600, 420);
fill(#FAF200);
ellipse(width/2+750, height/2-400, width/6, height/6);
textSize(50);
fill(#009FFF);
stroke(#FF039A);
text("Suivant", width/2+660, height/2-385);
if (mouseX>(width/2+750)-width/6) {
if (mouseX<width/2+750+width/6) {
if (mouseY>(height/2-400)-height/6) {
if (mouseY<(height/2-400)+height/6) {
if (mousePressed) {
page = 9 ;
background(#F2A9D5);
}
}
}
}
}
}
void page9 () {
fill(#000000);
textSize(30);
text("Replacez les différentes ondes électromagnétiques", width/4, height/3);
text("de la plus petite à la plus grande longueur d'onde", width/4+50, height/3+50);
fill(#FFFFFF);
image (imgspectre1, xspectre1, yspectre1, 150, 150);
image (imgspectre2, xspectre2, yspectre2, 200, 150);
image (imgspectre3, xspectre3, yspectre3, 150, 150);
fill(#0017FF);
textSize(20);
if ((mousePressed)&&(mouseX<xspectre1+150)&&(mouseX>xspectre1)&&(mouseY<yspectre1+150)&&(mouseY>yspectre1)) {
xspectre1=mouseX-75;
yspectre1=mouseY-75;
}
if ((mousePressed)&&(mouseX<xspectre2+200)&&(mouseX>xspectre2)&&(mouseY>yspectre2)&&(mouseY<yspectre2+150)) {
xspectre2=mouseX-75;
yspectre2=mouseY-75;
}
if ((mousePressed)&&(mouseX<xspectre3+150)&&(mouseX>xspectre3)&&(mouseY<yspectre3+150)&&(mouseY>yspectre3)) {
xspectre3=mouseX-75;
yspectre3=mouseY-75;
}
noFill();
stroke(#050000);
strokeWeight(5);
rect(width/4, height/2+200, 200, 150);
rect(width/2, height/2+200, 200, 150);
rect(width/2+width/4, height/2+200, 200, 150);
strokeWeight(10);
line(width/4, height/2+150, width-200, height/2+150);
triangle(width-205, height/2+145, width-200, height/2+150, width-205, height/2+155);
text("1pm", width/4, height/2+140);
text("10^3m", width-300, height/2+140);
textSize(50);
text("Valider", width/6-200, height/2);
frameRate (30);
if ((mouseX>width/6-250)&&(mouseX<width/6+50)&&(mouseY>height/2-50)&&(mouseY<height/2+50)) {
cursor(HAND);
if (mousePressed) {
if ((xspectre2>=width/4-20)&&(xspectre2<=width/4+150)&&(yspectre2>=height/2+180)&&(yspectre2<=height/2+350)) {
if ((xspectre3>=width/2-20)&&(xspectre3<=width/2+150)&&(yspectre3>=height/2+180)&&(yspectre3<=height/2+350)) {
if ((xspectre1>=width/2+width/4-20)&&(xspectre1<=width/2+width/4+150)&&(yspectre1>=height/2+180)&&(yspectre1<=height/2+350)) {
valider=true;
date=millis();
delay=millis()-oldDate;
println(delay);
if (delay>1000) {
score=score+1;
oldDate=millis();
}
}
else {
v=true;
}
}
else {
v=true;
}
}
else {
v=true;
}
}
}
if (valider==true) {
textSize(50);
text("Bravo!", width/2, height/2+100);
yeah4.play();
textSize (40);
fill(#FAF200);
text("suivant", width-150, height-150);
}
if (v==true) {
text("Perdu...", width/2, height/2+100);
cri5.play();
textSize (40);
fill(#FAF200);
text("suivant", width-150, height-150);
}
if (mouseX<width) {
if (mouseX>width-300) {
if (mouseY<height) {
if (mouseY>height-300) {
cursor(HAND);
if (mousePressed) {
page = 10;
background(#3439F7);
}
}
}
}
}
}
void page10 () {
frameRate(30);
fill(#4BFF00);
ellipse(width/2+750, height/2-400, width/6, height/6);
textSize(40);
fill(#FFFFFF);
text("Suivant", width/2+680, height/2-385);
fill(#009FFF);
textSize (150);
text("REPONSE", width/7 , height/5);
fill(#FF038A);
textSize(40);
text("Voici le spectre des ondes ", 400, height/4+50);
text("électromagnétiques. Les rayons visibles", 460, height/4+100);
text("sont les seuls que l'oeil perçoit.", 520, height/4+150);
image (img4, width/2+200,height/6 + 220, 550, 500);
if (mouseX>(width/2+750)-width/6) {
if (mouseX<width/2+750+width/6) {
if (mouseY>(height/2-400)-height/6) {
if (mouseY<(height/2-400)+height/6) {
if (mousePressed) {
page = 11 ;
}
}
}
}
}
}
void page11 () {
background(#000000);
textSize(70);
fill(#FF038A);
if(score==5){
text("Bravo, vous êtes prêts à passer le bac!",width/6,height/2+100);
}
if(score<5){
if(score>2){
text("Vous devriez revoir votre leçon.",width/6,height/2+100);
}
if(score<=2){
text("Vous êtes mauvais.",width/6,height/2+100);
}
}
textSize(100);
text("Score : "+score, width/4, height/3);//affichage du score
fill(#FFFFFF);
stroke(#FF038A);
rect(1710,height/2-340, 180, 700);
fill(#FF038A);
textSize(60);
text ("R", 1783, height/2-270);
text ("E", 1784, height/2-210);
text ("C", 1780, height/2-150);
text ("O", 1780, height/2-90);
text ("M", 1780, height/2-30);
text ("M", 1780, height/2+30);
text ("E",1784, height/2+90);
text ("N", 1780, height/2+150);
text ("C", 1780, height/2+210);
text ("E", 1784, height/2+270);
text ("R", 1783, height/2+330);
if (mouseX > 1710){
if (mouseX <1890){
if (mouseY > height/2-340){
if (mouseY < height/2+360){
if (mousePressed){
page=0;
score=0;
}
}
}
}
}
}




