Etat du programme

  • Onglet Principal


int page = 0;

void setup ()

{

  fullScreen();

  frameRate(60);

  //Onglet Image

  etat ();

  ChargerImageMenuPrincipal ();

  ChargerImageMenuContinuer ();

  ChargerImageChoixDuPersonnage ();

  ImagesSalles ();

  ImageObjets ();

  ImageDialogue();

  ImageMenuJeu ();

  //Onglet Police d'écriture

  setupPolice ();

  //Jeu

  setupDebutJeu ();

  setupJeu ();

  //Dialogues

  setupBDD ();

  //Menus

  setupMenuPrincipal ();

  setupMenuJeu ();

  //interaction des bouton

  setupBouton ();

  //interaction des Touches du clavier

  setupTouches ();

  //Page du programme

  page = 1;

  //Developpement

  setupDeveloppement();

}

void draw ()

{

  if (page == 1)

  {

    MenuPrincipal();

  }

  if (page == 2)

  {

    MenuContinuer ();

  }

  if ( page == 3)

  {

    DebutJeu ();

  }

  if (jeu == true)

  {

    Jeu ();

  }

  Developpement ();

  dynamismeTouches ();

  dynamismeBouton ();

  Touches ();

}

void mousePressed ()

{

  mousePressedMenuPrincipal ();

  mousePressedMenuContinuer ();

  mousePressedDebutJeu ();

  mousePressedMenuJeu ();

  }

void mouseReleased ()

{

  mouseReleasedMenuPrincipal ();

  mouseReleasedMenuContinuer ();

  mouseReleasedDebutJeu ();

  mouseReleasedMenuJeu ();

}

void keyPressed()

{

  keyPressedPerso();

  keyPressedAffichageMenu ();

  keyPressedAction ();

}

void keyReleased ()

{

  keyReleasedPerso();

  keyReleasedAffichageMenu ();

  keyRelaesedAction();

}

  • Onlget Action


boolean action = false; // Variable vérifiant si la touche d'action a été pressée près d'un objet

interactif

void keyPressedAction ()

{

  if (jeu == true)

  {

    if ( key == monTableauTouches [11] || key == monTableauTouches [12])

    {

      PressionTouche [11] = true;

    }

  }

}

void keyRelaesedAction()

{

  if (jeu == true)

  {

    if ( key == monTableauTouches [11] || key == monTableauTouches [12])

    {

      RelacherTouche [11] = true;

    }

  }

}

void Action ()

{

  if ( PressionTouche [11] == true &&  RelacherTouche [11] == true)

  {

    if (action == false)

    {

      action = true;

    } else

    {

      action = false;

    }

    PressionTouche [11] = false;

    RelacherTouche [11] = false;

  }

  if (action == true)

  {

    if (x > Game.width/2.4 && x < Game.width/2.4 + taillePersoX+ Game.width/48 + 3)

    {

      if (y > 37*Game.height/54 && y < 37*Game.height/54 + height/10.8  )

      {

        annonce = "Il y a un trou, mais c'est trop haut. \nPeut-être y a t-il quelque chose qui me

permettrait de l'atteindre.";

      } else

      {

        annonce = "Il y a une barrière";

      }

      affichageDialogue ();

      

    }

    else if ( (x > XObjet[1] - taillePersoX - 5 && x < XObjet[1]+2*taillePersoX+10) && (y >  YObjet[1] -

32*height/945 -5  && y + taillePersoY <  YObjet[1] - 32*height/945 -5 + 3*32*height/945 +15 )  )

    {

      if(tirer == false)

      {

      annonce = "Ce Tonneau est vide, je peut le faire bouger \n  Tirer le tonneau?";

      question[1] = true;

      affichageDialogue ();

      }

      if (tirer == true)

      {

        annonce = "Arrêter de tirer et juste pousser?";

        question[2] = true;

        affichageDialogue ();

      }

      

    }

    else

    {

      action = false; //Si Jamais la touche action n'est pas pressée près d'un objet interactif, action

reprend sa valeur false;

    }

  }

}

  • Onglet Boite de Dialogue


PGraphics BDD;

String annonce = "";

boolean question []= new boolean [10];  // Tableau de booléen vérifiant si l'ojet interactif conduit à

un choix.

float XChoix; //Variable de l'abscice de la flêche pour le choix de l'action à faire.

void setupBDD () //BDD: Boite de Dialogue

{

  annonce = "";

  BDD = createGraphics(width/2, height/8);

  XChoix = BDD.width/4- BDD.width/32 - height/90;

  for (int i =0;i<10; i++)

  {

    question [i]= false;

  }

}

void BoiteDeDialogue ()

{

  BDD.beginDraw();

  BDD.background(#B2AEAE);

  //BDD.textFont(RetroComputer);

  BDD.fill(0);

  BDD.textSize(height/45);

  BDD.textAlign(LEFT);

  BDD.text(annonce, 20, 30);

 

  if (question[1] == true)

  {

    BDD.textAlign(CENTER);

    BDD.text("OUI", BDD.width/4, 7*BDD.height/8);

    BDD.text("NON", 3*BDD.width/4, 7*BDD.height/8);

    BDD.triangle(XChoix, 7*BDD.height/8 - height/45 + height/135, XChoix, 7*BDD.height/8, XChoix +

sqrt(height*height/2700), 7*BDD.height/8 - height/90 + height/270);

    if (keyPressed)

    {

      if (key == CODED)

      {

        if (keyCode == RIGHT)

        {

          XChoix = 3*BDD.width/4- BDD.width/32 - height/90 - height/135;

        }

        if (keyCode == LEFT)

        {

          XChoix = BDD.width/4- BDD.width/32 - height/90;

        }

      }

      if (key == monTableauTouches [5] || key == monTableauTouches [6])

      {

        XChoix = 3*BDD.width/4- BDD.width/32 - height/90 - height/135;

      }

      if (key == monTableauTouches [7] || key == monTableauTouches [8])

      {

        XChoix = BDD.width/4- BDD.width/32 - height/90;

      }

    }

    if (key == monTableauTouches [11] || key == monTableauTouches [12])

    {

      if (XChoix == BDD.width/4- BDD.width/32 - height/90)

      {

        tirer = true;        

      }

      else

      {

        tirer = false;

      }

    }

  }

 println(tirer);

  BDD.endDraw();

}

void affichageDialogue ()

{

  image(BDD, width/4, 3*height/4 + height/32);

  if (sexe == 1 || sexe == 2)

  {

    image(DialoguePersoF,width-2*DialoguePersoF.width,height - 2*DialoguePersoF.height,

2*DialoguePersoF.width, 2*DialoguePersoF.height); // Affichage du layer de la boite de dialogue.

  }

}

  •  Onglet Bouton


int a [] = new int [30]; //variable permettant le changement d'aspect des boutons

boolean clicBouton [] = new boolean [30]; //booléen vérifiant le clic sur un bouton

boolean relacheBouton [] = new boolean [30]; //booléen vérifiant le relachement du bouton.

/*

  Menu Principal:

 1 : Bouton Continuer

 2 : Bouton Nouvelle Partie

 3 : Bouton Exit

 4 : Bouton Programmeur

 

 Menu Continuer:

 5 : Bouton Retour

 6 : Bouton Data 1

 7 : Bouton Data 2

 8 : Bouton Data 3


 Démarrage du jeu:

 9 : Bouton Fille

 10 : Bouton Garçon

 

 Menu du Jeu:

 11 : Bouton ContinuerJeu

 12 :

 13 : Bouton Paramètre

 14 : Bouton Quitter

 11 :

 */

 //Dans ce programme, lorsque le nom d'une fonction est entièrement en majuscule, c'est que son

rôle est d'afficher un bouton.

void setupBouton ()

{

  for (int i = 0; i<30; i++)

  {

    a[i] = 0;

    clicBouton [i] = false;

    relacheBouton [i] = false;

  }

}

void dynamismeBouton ()

{

  //menu Continuer

  if (clicBouton[1] == true && relacheBouton [1] == true)

  {

    page = 2;

    clicBouton[1] = false;

    relacheBouton [1] = false;

  }

  //Menu Novelle Partie

  if (clicBouton[2] == true && relacheBouton [2] == true)

  {

    page = 3;

    clicBouton[2] = false;

    relacheBouton [2] = false;

  }

  //Bouton d'arrêt du Jeu

  if (clicBouton[3] == true && relacheBouton [3] == true)

  {

    exit();

    clicBouton[3] = false;

    relacheBouton [3] = false;

  }

  if (clicBouton[4] == true && relacheBouton [4] == true)

  {

    setupModeProg ();

    clicBouton[4] = false;

    relacheBouton [4] = false;

  }

  if (clicBouton[5] == true && relacheBouton [5] == true)

  {

    page = 1;

    clicBouton[5] = false;

    relacheBouton [5] = false;

  }

  if (clicBouton[6] == true && relacheBouton [6] == true)

  {

    clicBouton[6] = false;

    relacheBouton [6] = false;

  }

  if (clicBouton[7] == true && relacheBouton [7] == true)

  {

    clicBouton[7] = false;

    relacheBouton [7] = false;

  }

  if (clicBouton[8] == true && relacheBouton [8] == true)

  {

    clicBouton[8] = false;

    relacheBouton [8] = false;

  }

  if (clicBouton[9] == true && relacheBouton [9] == true)

  {

    sexe = 1;

    clicBouton[9] = false;

    relacheBouton [9] = false;

  }

  if (clicBouton[10] == true && relacheBouton [10] == true)

  {

    sexe = 2;

    clicBouton[10] = false;

    relacheBouton [10] = false;

  }

  if (clicBouton[11] == true && relacheBouton [11] == true)

  {

    AfficherMenu = false;

    clicBouton[11] = false;

    relacheBouton [11] = false;

  }

  if (clicBouton[13] == true && relacheBouton [13] == true)

  {

    pageMenu = 1; // affichage du menu paramètre

    clicBouton[13] = false;

    relacheBouton [13] = false;

  }

  if (clicBouton[14] == true && relacheBouton [14] == true)

  {

    setup();

    clicBouton[14] = false;

    relacheBouton [14] = false;

  }

}

  • Onglet Début Jeu


boolean jeu = false;

int sexe = 0;

String Pseudo = " ";

boolean complet = false;

void setupDebutJeu ()

{

  jeu = false;

  sexe = 0;

  dossier1 = "F";

  M_F = "";

  extension = "";

}

void DebutJeu ()

{

  background(0);

  textAlign(CENTER);

  textFont(VelvetDream);

  textSize(height/9);

  text("Choisissez Votre Heros!", width/2, height/4);

  FILLE ();

  GRACON ();

  DebutPerso ();

  if (Pseudo == " ")

  {

    if (sexe == 1 || sexe == 2)

    {

      background(0);

      Pseudo ();

    }

  }

  if (complet == true)

  {

    if (sexe == 1 || sexe == 2)

    {

      page = 0;

      jeu = true;

    }

  }

}

void FILLE ()

{

  image(Bouton_F [ a[9] ], width/4, width/4, width/4 - 20, width/4 - 20);

  image(Perso_F,width/4 + width / 8,width/4 + width / 8);

  if ((mouseX>=width/4 && mouseX<=(width/4)+(width/4)-20) && (mouseY>=width/4 &&

mouseY<=(width/4)+(width/4)-20))

  {

    if (mousePressed)

    {

      a[9] = 2;

    } else

    {

      a[9] = 1;

    }

  } else

  {

    a[9] = 0;

  }

}

void GRACON ()

{

  image(Bouton_M [ a[10] ], (3*width)/4 + 20-(width/4), width/4, width/4-20, width/4 - 20);

  image(Perso_M,3*width/4 - width / 8,width/4 + width / 8);

  if ((mouseX>=(3*width)/4 + 20-(width/4) && mouseX<=(3*width)/4 + 20-(width/4)+(width/4)-20)

&& (mouseY>=width/4 && mouseY<=(width/4)+(width/4)-20))

  {

    if (mousePressed)

    {

      a[10] = 2;

    } else

    {

      a[10] = 1;

    }

  } else

  {

    a[10] = 0;

  }

}

void mousePressedDebutJeu ()

{

  if (page == 3)

  {

    if ((mouseX>=width/4 && mouseX<=(width/4)+(width/4)-20) && (mouseY>=width/4 &&

mouseY<=(width/4)+(width/4)-20))

    {

      clicBouton [9] = true;

    }

    if ((mouseX>=(3*width)/4 + 20-(width/4) && mouseX<=(3*width)/4 + 20-(width/4)+(width/4)-20)

&& (mouseY>=width/4 && mouseY<=(width/4)+(width/4)-20))

    {

      clicBouton [10] = true;

    }

  }

}

void mouseReleasedDebutJeu ()

{

  if (page == 3)

  {

    if ((mouseX>=width/4 && mouseX<=(width/4)+(width/4)-20) && (mouseY>=width/4 &&

mouseY<=(width/4)+(width/4)-20))

    {

      relacheBouton [9] = true;

    }

    if ((mouseX>=(3*width)/4 + 20-(width/4) && mouseX<=(3*width)/4 + 20-(width/4)+(width/4)-20)

&& (mouseY>=width/4 && mouseY<=(width/4)+(width/4)-20))

    {

      relacheBouton [10] = true;

    }

  }

}

void DebutPerso ()

{

  if ( sexe == 1)

  {

    M_F = "F ";

    extension = ".gif";

    dossier1 = "Femme";

  }

  if (sexe == 2)

  {

    M_F = "G ";

    extension = ".png";

    dossier1 = "Homme";

  }

}

void Pseudo ()

{

   Pseudo = new Dialog().readString("Entrez le nom du héros");

  if ( Pseudo.equals("") || Pseudo.equals(" "))

  {

    JOptionPane nope;

    {   

      //Boîte du message préventif

      nope = new JOptionPane();

      nope.showMessageDialog(null, "Merci d'entrer un code valide sans caractères spéciaux.",

"Erreur", JOptionPane.WARNING_MESSAGE);

    }

    complet = false;

    Pseudo();

  } else {

    complet = true;

  }

}

  • Onglet Jeu


PGraphics Game;

void setupJeu()

{  

  Game = createGraphics(width/2, height/2); //Le jeu est un layer posé sur le background.

  setupPersonnage ();

  setupSalle ();

}

void Jeu ()

{

  background(0);

  Game.beginDraw();

  maps();

  personnage();

  if (y<YObjet[1])

  {
    Objet ();
  }

  if (AfficherMenu == true)
  {

    menuJeu ();

  }

  Game.endDraw();

  BoiteDeDialogue ();

  Action ();

  image(Game, width/4, height/4); //Affichage du ayer contenant le jeu.

}

  • Onglet Menu Continuer


void MenuContinuer ()

{

  background(0);

  fill(#00FCEE);

  DATA1 ();

  DATA2 ();

  DATA3 ();

  RETOUR ();

}

void RETOUR ()

{

  image(BoutonRetour [ a[5] ], 25, 15, width/20, height/30);

  if ((mouseX>25 && mouseX<25+width/20) && (mouseY>15 && mouseY<15+height/30))

  {

    if (mousePressed)

    {

      a[5] = 2;

    } else

    {

      a[5] = 1;

    }

  } else

  {

    a[5] = 0;

  }

}

void DATA1 ()

{

  image(BoutonData1 [ a[6] ], 20, height/2, width/2-40, height/8);

  if ((mouseX>20 && mouseX<20 + width/2-40) && (mouseY>height/2 &&

mouseY<height/2+height/8))

  {

    if (mousePressed)

    {

      a[6] = 2;

    } else

    {

      a[6] = 1;

    }

  } else

  {

    a[6] = 0;

  }

}

void DATA2 ()

{

  image(BoutonData2 [ a[7] ], 20, height/2+height/8 + 10, width/2-40, height/8);

  if ((mouseX>20 && mouseX<20 + width/2-40) && (mouseY>height/2+height/8 + 10 &&

mouseY<height/2+height/8+height/8 + 10))

  {

    if (mousePressed)

    {

      a[7] = 2;

    } else

    {

      a[7] = 1;

    }

  } else

  {

    a[7] = 0;

  }

}

void DATA3 ()

{

  image(BoutonData3 [ a[8] ], 20, height/2+2*(height/8 + 10), width/2-40, height/8);

  if ((mouseX>20 && mouseX<20 + width/2-40) && (mouseY>height/2+2*(height/8 + 10) &&

mouseY<height/2+height/8+2*(height/8 + 10)))

  {

    if (mousePressed)

    {

      a[8] = 2;

    } else

    {

      a[8] = 1;

    }

  } else

  {

    a[8] = 0;

  }

}

void mousePressedMenuContinuer ()

{

  if (page == 2)

  {

    if ((mouseX>25 && mouseX<25+width/20) && (mouseY>15 && mouseY<15+height/30))

    {

      clicBouton [5] = true;

    }

  }

}

void mouseReleasedMenuContinuer ()

{

  if ( page == 2)

  {

    if ((mouseX>25 && mouseX<25+width/20) && (mouseY>15 && mouseY<15+height/30))

    {

      relacheBouton [5] = true;

    }

  }

}

  • Onlget Menu Jeu


PGraphics Menu;

int pageMenu = 0;

boolean AfficherMenu = false;

void setupMenuJeu ()

{

  Menu = createGraphics(3*Game.width/4, 3*Game.height/4);

  pageMenu = 0;

  AfficherMenu = false;

}

void menuJeu ()

{

  Menu.beginDraw();

  Game.textSize(32);

  Game.fill(#FF0004);

  Game.textAlign(CENTER);

  Game.text("Menu", (Game.width/2), 30);

  Menu.background(#6F7470, 155);

  Menu.fill(#969897);

  if (pageMenu == 0)

  {

    CONTINUERJEU (); //continuer

    Menu.rect(Menu.width/4, Menu.height/4, Menu.width/2, Menu.height/8 + Menu.height/16);

    PARAMETRE (); //paramètres

    QUITTERJEU (); //quitter le jeu    

    Menu.endDraw();

  }

  Game.image(Menu, Game.width/8, Game.height/8);

 

 

}

void keyPressedAffichageMenu ()

{

 

  if (jeu == true)

  {

    if (key == monTableauTouches [9] || key == monTableauTouches [10])

    {

      PressionTouche [9] = true;

    }

  }

}

void keyReleasedAffichageMenu ()

{

  if (jeu == true)

  {

    if (key == monTableauTouches [9] || key == monTableauTouches [10])

    {

        RelacherTouche [9] = true;

        

      

    }

  }

}

void mousePressedMenuJeu ()

{

  if ((mouseX>width/4 + Game.width/8 + Menu.width/4 && mouseX < width/4 + Game.width/8 +

Menu.width/4 + Menu.width/2) && (mouseY> height/4 + Game.height/8 + Menu.height/32 &&

mouseY < height/4 + Game.height/8 + Menu.height/32 + Menu.height/8 + Menu.height/16))

  {

    clicBouton [11] = true;

  }

  if ((mouseX>width/4 + Game.width/8 + Menu.width/4 && mouseX < width/4 + Game.width/8 +

Menu.width/4 + Menu.width/2) && (mouseY> height/4 + Game.height/8 + Menu.height/32 &&

mouseY < height/4 + Game.height/8 + Menu.height/32 + Menu.height/8 + Menu.height/16))

  {

    clicBouton [13] = true;

  }

  if ((mouseX>width/4 + Game.width/8 + Menu.width/4 && mouseX < width/4 + Game.width/8 +

Menu.width/4 + Menu.width/2) && (mouseY> height/4 + Game.height/8 + Menu.height/4 +

Menu.height/8 + Menu.height/16+ Menu.height/32 + Menu.height/8 + Menu.height/16 +

Menu.height/32 && mouseY < height/4 + Game.height/8 + Menu.height/4 + Menu.height/8 +

Menu.height/16+ Menu.height/32 + Menu.height/8 + Menu.height/16 + Menu.height/32 +

Menu.height/8 + Menu.height/16))

  {

    clicBouton [14] = true;

  }

}

void mouseReleasedMenuJeu ()

{

  if ((mouseX>width/4 + Game.width/8 + Menu.width/4 && mouseX < width/4 + Game.width/8 +

Menu.width/4 + Menu.width/2) && (mouseY> height/4 + Game.height/8 + Menu.height/32 &&

mouseY < height/4 + Game.height/8 + Menu.height/32 + Menu.height/8 + Menu.height/16))

  {

    relacheBouton [11] = true;

  }

  if ((mouseX>width/4 + Game.width/8 + Menu.width/4 && mouseX < width/4 + Game.width/8 +

Menu.width/4 + Menu.width/2) && (mouseY> height/4 + Game.height/8 + Menu.height/32 &&

mouseY < height/4 + Game.height/8 + Menu.height/32 + Menu.height/8 + Menu.height/16))

  {

    relacheBouton [13] = true;

  }

  if ((mouseX>width/4 + Game.width/8 + Menu.width/4 && mouseX < width/4 + Game.width/8 +

Menu.width/4 + Menu.width/2) && (mouseY> height/4 + Game.height/8 + Menu.height/4 +

Menu.height/8 + Menu.height/16+ Menu.height/32 + Menu.height/8 + Menu.height/16 +

Menu.height/32 && mouseY < height/4 + Game.height/8 + Menu.height/4 + Menu.height/8 +

Menu.height/16+ Menu.height/32 + Menu.height/8 + Menu.height/16 + Menu.height/32 +

Menu.height/8 + Menu.height/16))

  {

    relacheBouton [14] = true;

  }

}

void CONTINUERJEU ()

{

  Menu.image(BoutonContinuerJeu [ a[11] ], Menu.width/4, Menu.height/32,Menu.width/2,

Menu.height/8 + Menu.height/16);

  if ((mouseX>width/4 + Game.width/8 + Menu.width/4 && mouseX < width/4 + Game.width/8 +

Menu.width/4 + Menu.width/2) && (mouseY> height/4 + Game.height/8 + Menu.height/32 &&

mouseY < height/4 + Game.height/8 + Menu.height/32 + Menu.height/8 + Menu.height/16))

  {

    if (mousePressed)

    {

      a[11] = 2;

    } else

    {

      a[11] = 1;

    }

  } else

  {

    a[11] = 0;

  }

}

void PARAMETRE ()

{

  Menu.image(BoutonParametre [ a[13] ], Menu.width/4, Menu.height/4 + Menu.height/8 +

Menu.height/16+ Menu.height/32, Menu.width/2, Menu.height/8 + Menu.height/16);

  if ((mouseX>width/4 + Game.width/8 + Menu.width/4 && mouseX < width/4 + Game.width/8 +

Menu.width/4 + Menu.width/2) && (mouseY> height/4 + Game.height/8 + Menu.height/32 &&

mouseY < height/4 + Game.height/8 + Menu.height/32 + Menu.height/8 + Menu.height/16))

  {

    if (mousePressed)

    {

      a[13] = 2;

    } else

    {

      a[13] = 1;

    }

  } else

  {

    a[13] = 0;

  }

}

void QUITTERJEU ()

{

  Menu.image(BoutonQuitterJeu [ a[14] ], Menu.width/4, Menu.height/4 + Menu.height/8 +

Menu.height/16+ Menu.height/32 + Menu.height/8 + Menu.height/16 + Menu.height/32,

Menu.width/2, Menu.height/8 + Menu.height/16);

  if ((mouseX>width/4 + Game.width/8 + Menu.width/4 && mouseX < width/4 + Game.width/8 +

Menu.width/4 + Menu.width/2) && (mouseY> height/4 + Game.height/8 + Menu.height/4 +

Menu.height/8 + Menu.height/16+ Menu.height/32 + Menu.height/8 + Menu.height/16 +

Menu.height/32 && mouseY < height/4 + Game.height/8 + Menu.height/4 + Menu.height/8 +

Menu.height/16+ Menu.height/32 + Menu.height/8 + Menu.height/16 + Menu.height/32 +

Menu.height/8 + Menu.height/16))

  {

    if (mousePressed)

    {

      a[14] = 2;

    } else

    {

      a[14] = 1;

    }

  } else

  {

    a[14] = 0;

  }

}

  • Onglet Menu Principal


void setupMenuPrincipal ()

{

}

void MenuPrincipal()

{

  background(0);

  CONTINUER ();

  NOUVELLEPARTIE ();

  QUITTER ();

  PROG ();

}

void CONTINUER ()

{

  image (BoutonContinuer[ a[1] ], width/2 - width/8, height/2, width/4, height/8-height/32);

  if (  (mouseX >= width/2 - width/8  && mouseX <= width/2 + width/8) && (mouseY >= height/2 &&

mouseY <= height/2 + height/8 - height/32)   )

  {

    if (mousePressed)

    {

      a[1] = 2;

    } else

    {

      a[1] = 1;

    }

  } else

  {

    a[1] = 0;

  }

}

void NOUVELLEPARTIE ()

{

  image(BoutonNouvellePartie [ a[2] ], width/2 - width/8, height/2+ height/8, width/4, height/8-

height/32);

  if (  (mouseX >= width/2 - width/8  && mouseX <= width/2 + width/8) && (mouseY >=

height/2+height/8 && mouseY <= height/2 + height/4 - height/32)   )

  {

    if (mousePressed)

    {

      a[2] = 2;

    } else

    {

      a[2] = 1;

    }

  } else

  {

    a[2] = 0;

  }

}

void QUITTER ()

{

  image(BoutonExit [ a[3] ], width/2 - width/8, height/2+ 2*height/8, width/4, height/8-height/32);

  if (  (mouseX >= width/2 - width/8  && mouseX <= width/2 + width/8) && (mouseY >= height/2+

2*height/8 && mouseY <= height/2 + 3*height/8 - height/32)   )

  {

    if (mousePressed)

    {

      a[3] = 2;

    } else

    {

      a[3] = 1;

    }

  } else

  {

    a[3] = 0;

  }

}

void PROG ()

{

  image (BoutonProgrammeur [ a[4] ], width - width/4 + width/8 - 20, height-height/8+ 2*height/32 -

20, width/4- width/8 ,  height/8- 2*height/32  );

  if ((mouseX>=width - width/4 + width/8-20 && mouseX<=width -20) && (mouseY>height-height/8+

2*height/32 -20 && mouseY<height-20))

  {

   if (mousePressed)

    {

      a[4] = 2;

    } else

    {

      a[4] = 1;

    }

  } else

  {

    a[4] = 0;

  }

}

void mousePressedMenuPrincipal ()

{

  if (page == 1)

  {

    if (  (mouseX >= width/2 - width/8  && mouseX <= width/2 + width/8) && (mouseY >= height/2 &&

mouseY <= height/2 + height/8 - height/32)   )

    {

      clicBouton [1] = true;

    }

    if (  (mouseX >= width/2 - width/8  && mouseX <= width/2 + width/8) && (mouseY >=

height/2+height/8 && mouseY <= height/2 + height/4 - height/32)   )

    {

      clicBouton [2] = true;

    }

    if (  (mouseX >= width/2 - width/8  && mouseX <= width/2 + width/8) && (mouseY >= height/2+

2*height/8 && mouseY <= height/2 + 3*height/8 - 2*height/32)   )

    {

      clicBouton [3] = true;

    }

    if ((mouseX>=width - width/4 + width/8-20 && mouseX<=width -20) && (mouseY>height-

height/8+ 2*height/32 -20 && mouseY<height-20))

    {

      clicBouton [4] = true;

    }

  }

}

void mouseReleasedMenuPrincipal ()

{

  if (page == 1)

  {

    if (  (mouseX >= width/2 - width/8  && mouseX <= width/2 + width/8) && (mouseY >= height/2 &&

mouseY <= height/2 + height/8 - height/32)   )

    {

        relacheBouton [1] = true;

    }

    if (  (mouseX >= width/2 - width/8  && mouseX <= width/2 + width/8) && (mouseY >=

height/2+height/8 && mouseY <= height/2 + height/4 - height/32)   )

    {

      relacheBouton [2] = true;

    }

    if (  (mouseX >= width/2 - width/8  && mouseX <= width/2 + width/8) && (mouseY >= height/2+

2*height/8 && mouseY <= height/2 + 3*height/8 - 2*height/32)   )

    {

      relacheBouton [3] = true;

    }

    if ((mouseX>=width - width/4 + width/8-20 && mouseX<=width -20) && (mouseY>height-

height/8+ 2*height/32 -20 && mouseY<height-20))

    {

      relacheBouton [4] = true;

    }

  }

}

  •  Onglet Mode programmeur


PGraphics Programmeur;

boolean prog = false;

boolean demande = false;

String code = "";

import javax.swing.JOptionPane;

import readBox.*;

void setupDeveloppement()

{

  Programmeur = createGraphics(width, height);

}

void setupModeProg ()

{

  if (prog == false)

  {

    demande = true;

  }

  if (prog == true)

  {

    prog = false;

    code = "";

  }

}

void Developpement ()

{

  demandeCode ();

}

void demandeCode ()

{

  if (demande == true)

  {

    code = new Dialog().readString("Entrez le code pour déverrouiller les paramètres");

  }

  if (code.equals("123456789"))

  {

    prog = true;

    demande = false;

  } else

  {

    if (demande == true)

    {

      //boite de dialogue attention

      JOptionPane attention;

      {   

        //Boîte du message préventif

        attention = new JOptionPane();

        attention.showMessageDialog(null, "Le code n'est pas bon", "Erreur",

JOptionPane.WARNING_MESSAGE);

      }

    }

    demande = false;

    println(code);

  }

  if (prog == true)

  {

    modeProg ();

  }

}

void modeProg ()

{

  Programmeur.beginDraw();

  Programmeur.background(255, 0);

  Programmeur.fill(255);

  Programmeur.stroke(0);

  Programmeur.textFont(police);  

  Programmeur.textAlign(CENTER);

  Programmeur.text("Mode programmeur", width/2, width/33.75);

  Programmeur.textAlign(LEFT);

  Programmeur.textSize(height/45);

  Programmeur.text("X: " + mouseX, 20, height-50);

  Programmeur.text("Y: "+ mouseY, 20, height-20);

  if (jeu == true)

  {

    Programmeur.textAlign(LEFT);

    Programmeur.text("Position du Joueur en X: " + x, 3*width/4, 50);

    Programmeur.text("Position du Joueur en Y: " + y, 3*width/4, 75);

  }

  if (jeu == false)

  {

    Programmeur.text("Page: " + page, width-250, 50);

  }

  Programmeur.stroke(#002CFF);

  Programmeur.line(0,mouseY, width,mouseY);

  Programmeur.line(mouseX,0, mouseX,height);

  Programmeur.endDraw();

  image(Programmeur, 0, 0);

}

  •  Onlget Obstacle


void BlocagePerso()

{

  if (lieu == 0)

  {

    noFill();

    noStroke();

    rect(Game.width/2.4, 0, Game.width/48, Game.height);

  }

}

void keyPressedObstacle ()

{

  if (lieu == 0)

  {

    KeyPressedObstacleSalle0 ();

  }

}

void KeyPressedObstacleSalle0 ()

{

  if (keyCode == RIGHT)

  {

    if ( x + taillePersoX > Game.width/2.4 && x+taillePersoX < 7*Game.width/16)

    {

      x = x;

    } else {

      x = x + Game.width/320;

      chronoP = chronoP+1;

    }

  }

  if (keyCode == LEFT)

  {

    if (x > Game.width/2.4 && x < 7*Game.width/16)

    {

      x = x;

    } else

    {

      x = x - Game.width/320;

      chronoP = chronoP+1;

    }

  }

  if (key == monTableauTouches [3])

  {

    if ( x + taillePersoX > Game.width/2.4 && x +  taillePersoX< 7*Game.width/16)

    {

      x = x;

    } else {

      x = x + Game.width/320;

      chronoP = chronoP+1;

    }

  }

  if (key == monTableauTouches [4])

  {

    if (x > Game.width/2.4 && x < 7*Game.width/16)

    {

      x = x;

    } else

    {

      x = x - Game.width/320;

      chronoP = chronoP+1;

    }

  }

}

  •  Onglet Personnage et mouvement


float x;

float y;

float taillePersoX = width/60;

float taillePersoY = height/ 22.5;

int chronoP = 0;

int pas = 0;

void setupPersonnage ()

{

  taillePersoX = width/60;

  taillePersoY = height/ 22.5;

  x = Game.width/2;

  y = Game.height/2;

}

void personnage ()

{

  if (chronoP > 5)

  {

    pas = pas + 1;

    chronoP = 0;

  }

  if (pas > 3)

  {

    pas = 0;

  }

  ImagePerso ();

  Game.image(Perso, x, y, taillePersoX, taillePersoY );

}

void keyPressedPerso()

{

  if (key == CODED)

  {

    if (keyCode == DOWN)

    {

      dossier2 = "Descendre";

      position = "D ";

      if (y>Game.height-taillePersoY)

      {

        y=y;

        pas=0;

        chronoP = 3;

      } else

      {

        keyPressedObstacle ();

        chronoP = chronoP+1;

        y = y + Game.height/180;

      }

    }

    if (keyCode == UP)

    {

      dossier2 = "Monter";

      position = "U ";

      if (y<15)

      {

        y=y;

        pas=0;

        chronoP = 3;

      } else

      {

        keyPressedObstacle ();

        chronoP = chronoP+1;

        y = y - Game.height/180;

      }

    }

    if (keyCode == RIGHT)

    {

      dossier2 = "Droite";

      position = "R ";

      if (x>Game.width- taillePersoX)

      {

        x=x;

        pas=0;

        chronoP = 3;

      } else

      {

        keyPressedObstacle ();

      }

    }

    if (keyCode == LEFT)

    {

      dossier2 = "Gauche";

      position = "L ";

      if (x<0)

      {

        x=x;

        pas=0;

        chronoP = 3;

      } else

      {

        keyPressedObstacle ();

      }

    }

  }

  if (key == monTableauTouches [3] || key == monTableauTouches [4])

  {

    dossier2 = "Descendre";

    position = "D ";

    if (y>Game.height-taillePersoY)

    {

      y=y;

      pas=0;

      chronoP = 3;

    } else

    {

      keyPressedObstacle ();

      chronoP = chronoP+1;

      y = y + Game.height/180;

    }

  }

  if (key == monTableauTouches [1] || key == monTableauTouches [2])

  {

    dossier2 = "Monter";

    position = "U ";

    if (y<15)

    {

      y=y;

      pas=0;

      chronoP = 3;

    } else

    {

      keyPressedObstacle ();

      chronoP = chronoP+1;

      y = y - Game.height/180;

    }

  }

  if (key == monTableauTouches [5] || key == monTableauTouches [6])

  {

    dossier2 = "Droite";

    position = "R ";

    if (x>Game.width-taillePersoX)

    {

      x=x;

      pas=0;

      chronoP = 3;

    } else

    {

      keyPressedObstacle ();

      x = x + 3;

      chronoP = chronoP+1;

    }

  }

  if (key == monTableauTouches [7] || key == monTableauTouches [8])

  {

    dossier2 = "Gauche";

    position = "L ";

    if (x<0)

    {

      x=x;

      pas=0;

      chronoP = 3;

    } else

    {

      keyPressedObstacle ();

      x = x - 3;

      chronoP = chronoP+1;

    }

  }

}

void keyReleasedPerso()

{

  if (key == CODED)

  {

    if (keyCode == DOWN || keyCode == UP || keyCode == RIGHT || keyCode == LEFT)

    {

      chronoP = 3;

      pas=0;

    }

  }

  if (key == monTableauTouches [1] || key == monTableauTouches [2] || key == monTableauTouches

[3] || key == monTableauTouches [4] || key == monTableauTouches [5] || key ==

monTableauTouches [6] || key == monTableauTouches [7] || key == monTableauTouches [8])

  {

    chronoP=3;

    pas=0;

  }

}

  •  Onglet des polices d'écritures


PFont police;

PFont RetroComputer;

PFont BTTF;

PFont csRegular;

PFont VelvetDream;

void setupPolice ()

{

    police = createFont("Fonts/D Day Stencil.ttf",width/33.75);   

    RetroComputer = createFont("Fonts/Retro Computer_DEMO.ttf",width/33.75);

    BTTF = createFont("Fonts/BTTF.ttf",width/33.75);

    csRegular = createFont("Fonts/cs_regular.ttf",width/33.75);

    VelvetDream = createFont("Fonts/Velvet Dream.ttf", 62);

    

}

 

  • Onglet Salle et Objets


int lieu = 0;

float XObjet [] = new float [10];

float YObjet [] = new float [10];

boolean tirer = false;

void setupSalle ()

{

  lieu = 0;

  XObjet[1] = 61*Game.width/64;

  YObjet[1] = 11*Game.height/27;

}

void maps ()

{

  Game.image(Salles [lieu], 0, 0, Game.width, Game.height);

  if (y>=YObjet[1])

  {

    Objet ();

  }

  dynamiserObjet ();

}

void Objet ()

{

  if (lieu == 0)

  {

    Game.image(tonneau, XObjet[1], YObjet[1], taillePersoX, 32*height/945);

    Game.fill(255, 0);

    Game.stroke(0,0);

    Game.rect(XObjet[1], YObjet[1], taillePersoX, 32*height/945);

    Game.rect(XObjet[1] - taillePersoX - 5, YObjet[1] - 32*height/945 -5, 3*taillePersoX+15,

3*32*height/945 +15);

    Game.rect(Game.width/2.4, 37*Game.height/54, taillePersoX+ Game.width/48 + 3, height/10.8);

    //Rectangle de blocage.

  }

}

/*ID Objet:

 1: Tonneau

 2:

 */

void dynamiserObjet ()

{

  //Objet 1

  if (keyPressed)

  {

    if (key == CODED)

    {

      if (x>XObjet[1]-10 && x< XObjet[1] + taillePersoX -10)

      {

        if (keyCode == DOWN)

        {

          if (tirer == false)

          {

            if (y > YObjet[1] -30 && y < YObjet[1] + 30)

            {

              if (YObjet[1] + 32*height/945 > Game.height-1)

              {

                y = y;

                YObjet[1] = YObjet[1];

              } else

              {

                YObjet [1] = YObjet[1] + Game.height/180;

              }

            }

          }

          if (tirer == true)

          {

            

          }

        }

        if (keyCode == UP)

        {

          if (tirer == false)

          {

            if (y<YObjet[1]+20 && y > YObjet[1])

            {

              if (YObjet[1]  < 32)

              {

                y = y;

                YObjet[1] = YObjet[1];

              } else

              {

                YObjet [1] = YObjet[1] - Game.height/180;

              }

            }

          }

          if (tirer == true)

          {

            

          }

        }

      }

      if (y > YObjet[1] -30 && y < YObjet[1])

      {

        if (keyCode == RIGHT)

        {

          if (tirer == false)

          {

            if (x> XObjet[1]-taillePersoX - 1 && x<XObjet[1] + taillePersoX/2)

            {

              if (XObjet[1] + taillePersoX > Game.width)

              {

                x= x;

                XObjet[1] = XObjet[1];

              } else

              {

                XObjet[1] = XObjet[1] + Game.width/320;

              }

            }

          }

           if (tirer == true)

          {

            

          }

        }

        if (keyCode == LEFT)

        {

          if (tirer == false)

          {

            if (x> XObjet[1] + taillePersoX/2 && x<XObjet[1] + 2*taillePersoX + 1)

            {

              if (XObjet[1] < Game.width/2.4 + Game.width/48 + 1)

              {

                x= x;

                XObjet[1] = XObjet[1];

              } else

              {

                XObjet[1] = XObjet[1] - Game.width/320;

              }

            }

          }

          if (tirer == true)

          {
          }

        }

      }

    }

  }

}

  • Onglet Sauvegarde


boolean save1 = false;

boolean save2 = false;

boolean save3 = false;

int choosenSave = 0;

int choosenLoad = 0;

PrintWriter data1;

PGraphics enregistrer;

void setupSauvegarde ()

{

  data1 = createWriter("Save/data1.txt");

  enregistrer = createGraphics(width/8, height/8); // menu de sauvegarde

}  

void Sauvegarde ()

{

  if (choosenSave == 1)

  {

    data1.println(lieu);

    data1.println(x);

    data1.println(y);

    data1.println(position);

    data1.println(dossier1);

    data1.println(dossier2);

    data1.println(M_F);

    data1.println(extension);

    data1.println(Pseudo);

    //data1.println(didacticiel);

    

    data1.flush();

    data1.close();

  }

}

void ExecuteData1 ()

{

  if (save1 == false)

  {

    save1 = true;

  }

}

void Charger ()

{

  if (choosenLoad == 1)

  {

    

  }

}

//sauvegarde à des point précis du jeu

void MenuSauver ()

{

  //a la borne de sauvegarde

 

}

  •  Onlget Touche


char monTableauTouches [] = new char [20];

boolean PressionTouche [] = new boolean [20];

boolean RelacherTouche [] = new boolean [20];

void setupTouches ()

{

  for (int i=0; i<10; i++)

  {

    PressionTouche [i] = false;

    RelacherTouche [i] = false;

  }

}

void Touches ()

{

  monTableauTouches [1] = 0; //Avancer

  monTableauTouches [2] = char(monTableauTouches [1]-32);

  monTableauTouches [3] = 0; //Reculer

  monTableauTouches [4] = char(monTableauTouches [3]-32);

  monTableauTouches [5] = 0; //Aller à droite

  monTableauTouches [6] = char(monTableauTouches [5]-32);

  monTableauTouches [7] = 0; // Aller à gauche

  monTableauTouches [8] = char(monTableauTouches [7] - 32);

  monTableauTouches [9] = 'm';

  monTableauTouches [10] = char(monTableauTouches [9]-32);

  monTableauTouches [11] = 'e';

  monTableauTouches [12] = char(monTableauTouches [11]-32);

  monTableauTouches [13] = 'i'; //inventaire

  monTableauTouches [14] = char(monTableauTouches [13] -32);

}

void dynamismeTouches ()

{

  if (jeu == true)

  {

    if (PressionTouche [9] == true && RelacherTouche [9] == true)

    {

      if ( AfficherMenu == false)

      {

        AfficherMenu = true;

      } else

      {    

        AfficherMenu = false;

      }

      PressionTouche [9] = false;

      RelacherTouche [9] = false;

    }

  }

}

  • Onlget Image


/*Rappel:

 

 - 1 : Base

 - 2 : Souris

 - 3 : Clic

 */

String Etat [] = new String [3];

void etat ()

{

  Etat [0] = " Base";

  Etat [1] = " Souris";

  Etat [2] = " Clic";

}

// Menu Principal

PImage BoutonContinuer [] = new PImage [3];

PImage BoutonNouvellePartie [] = new PImage [3];

PImage BoutonExit [] = new PImage [3];

PImage BoutonProgrammeur [] = new PImage [3];

void ChargerImageMenuPrincipal ()

{

  for (int i = 0; i<3; i++)

  {

    BoutonContinuer [i] = loadImage("Bouton/MenuPrincipal/Continuer" + Etat[i] + ".png");

    BoutonNouvellePartie [i] = loadImage("Bouton/MenuPrincipal/NouvellePartie" + Etat [i] + ".png");

    BoutonExit [i] = loadImage ("Bouton/MenuPrincipal/Quitter" + Etat [i] + ".png");

    BoutonProgrammeur [i] = loadImage ("Bouton/MenuPrincipal/Prog" + Etat [i] + ".png");

  }

}

//Menu Continuer

PImage BoutonRetour [] = new PImage [3];

PImage BoutonData1 [] = new PImage [3];

PImage BoutonData2 [] = new PImage [3];

PImage BoutonData3 [] = new PImage [3];

void ChargerImageMenuContinuer ()

{

  for (int i = 0; i< 3; i++)

  {

    BoutonRetour [i] = loadImage ("Bouton/MenuContinuer/Retour" + Etat [i] + ".png");

    BoutonData1 [i] = loadImage ("Bouton/MenuContinuer/Data1" + Etat [i] + ".png");

    BoutonData2 [i] = loadImage ("Bouton/MenuContinuer/Data2" + Etat [i] + ".png");

    BoutonData3 [i] = loadImage ("Bouton/MenuContinuer/Data3" + Etat [i] + ".png");

  }

}

// Choix Du personnage

PImage Bouton_M [] = new PImage [3];

PImage Bouton_F [] = new PImage [3];

PImage Perso_M;

PImage Perso_F;

void ChargerImageChoixDuPersonnage ()

{

  for (int i = 0; i < 3; i++)

  {

    Bouton_F [i] = loadImage("Bouton/ChoixDuPerso/Fille"+ Etat[i]+".png");

    Bouton_M [i] = loadImage("Bouton/ChoixDuPerso/Mec" + Etat[i]+".png");

  }

  Perso_M = loadImage("Bouton/ChoixDuPerso/Perso_M.png");

  Perso_F = loadImage("Bouton/ChoixDuPerso/Perso_F.gif");

}

// Menu  du Jeu

PImage BoutonContinuerJeu [] = new PImage [3];

//PImage Bouton... [] = new PImage [3];

PImage BoutonParametre [] = new PImage [3];

PImage BoutonQuitterJeu [] = new PImage [3];

void ImageMenuJeu ()

{

  for (int i = 0; i < 3; i++)

  {

    BoutonContinuerJeu [i] = loadImage("Bouton/MenuJeu/ContinuerJeu" + Etat[i]+ ".png");

    

    BoutonParametre [i] = loadImage("Bouton/MenuJeu/Paramètres" + Etat[i]+ ".png");

    BoutonQuitterJeu [i] = loadImage("Bouton/MenuJeu/QuitterLeJeu" + Etat[i]+ ".png");

    

  }

}

//Salles

PImage Salles [] = new PImage [5];

void ImagesSalles ()

{

  Salles [0] = loadImage("Salles/Salle 0.png");

  //Salles [1] =

}

PImage tonneau;

PImage PDS; //point de sauvegarde

PImage petiteTable;

PImage porte;

void ImageObjets ()

{

  tonneau = loadImage("Salles/Objet/Tonneau.png");

  PDS = loadImage ("Salles/Objet/JukeBox sauvegarde.png");

  petiteTable = loadImage ("Salles/Objet/Petite Table.png");

  porte = loadImage ("Salles/Objet/porte.png");

}

//Personnage

PImage Perso;

PImage DialoguePersoF;

PImage DialoguePersoM;

/* Pour une question de simplicité, l'image du personnage est chargée dans draw permettant ainsi de

changer

 plus facilement d'image pour les déplacement.*/

String dossier2 = "Descendre";

String position = "D ";

String dossier1 = "F";

String M_F = "";

String extension = "";

void ImageDialogue()

{

  DialoguePersoF = loadImage("Personnage/Femme/DIALOGUE/Dialogue_F.png");

  //DialoguePersoM = loadImage("Personnage/Homme/DIALOGUE/Dialogue_M.png");

}

void ImagePerso ()

{

  Perso = loadImage("Personnage/" + dossier1 + "/" + dossier2 + "/" + position + M_F + pas +

extension);

}