Esempio n. 1
0
  private void go() {

    Grille grille_game = pan.get_grille();
    grille_game.setMairie(3, 4);
    grille_game.setRoute(2, 4);
    try {
      Thread.sleep(3);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
 /** Effectue differentes actions en fonction du bouton que l'on clique */
 @Override
 public void actionPerformed(ActionEvent e) {
   if (e.getActionCommand().equals("Réinitialiser")) {
     this.maGrille.viderTabCases();
   } else if (e.getActionCommand().equals("Aléatoire")) {
     this.maGrille.remplirAleatTabCases();
   } else if (e.getActionCommand().equals("Chemin")) {
     this.etat = (byte) 0;
     this.indication.setEtat((byte) 0);
   } else if (e.getActionCommand().equals("Mur")) {
     this.etat = (byte) 1;
     this.indication.setEtat((byte) 1);
   } else if (e.getActionCommand().equals("Perso")) {
     this.etat = (byte) 2;
     this.indication.setEtat((byte) 2);
   } else if (e.getActionCommand().equals("Sortie")) {
     this.etat = (byte) 3;
     this.indication.setEtat((byte) 3);
   } else if (e.getActionCommand().equals("Sauvegarder")) {
     /* appel de la methode mapSaver */
     JFileChooser chooser = new JFileChooser("./MAP/");
     FileNameExtensionFilter filter = new FileNameExtensionFilter("Labyrinthe file (.lab)", "lab");
     chooser.setFileFilter(filter);
     int returnval = chooser.showOpenDialog(null);
     if (returnval == JFileChooser.APPROVE_OPTION) {
       System.out.println("You chose to save this file: " + chooser.getSelectedFile().getName());
       MapSaver map =
           new MapSaver(
               chooser.getSelectedFile(),
               (byte) this.maGrille.getTaille(),
               this.maGrille.getPosThesee(),
               this.maGrille.getPosSortie(),
               this.maGrille.getTabCases());
     } else {
       System.out.println("saving file aborded!");
     }
   } else if (e.getActionCommand().equals("Retour")) {
     /* retour au menu precedent */
     this.oldFenetre.setVisible(true);
     this.oldFenetre.repaint();
     this.maGrille.setClosed();
   }
   if (maGrille.estValide()) {
     this.sauvegarder.setEnabled(true);
   } else {
     this.sauvegarder.setEnabled(false);
   }
 }
 /**
  * Constructeur standard qui créé une balle de vitesse 1.
  *
  * @param maGrille la grille dans laquelle ajoutée une balle
  * @throws InvalidPositionException
  * @throws InvalidStateException
  */
 public Balle(Grille maGrille) throws InvalidStateException, InvalidPositionException {
   this.vitesse = 1;
   Position initBallePosition = new Position(10, 1);
   maGrille.changeStateAt(initBallePosition, TypeCase.BALLE);
 }