diff --git a/CASE/Case.class b/CASE/Case.class index 91cfb37..41c6fa6 100644 Binary files a/CASE/Case.class and b/CASE/Case.class differ diff --git a/CASE/Case.java b/CASE/Case.java index 2f4c21b..cb03caf 100644 --- a/CASE/Case.java +++ b/CASE/Case.java @@ -13,7 +13,6 @@ public class Case extends JComponent{ private int voisin; //Le nombre de mine aux alentours private int suspition; // son Etat de suspition ( 0:pas une bombe, 1:en est une, 2:je doute) // Les Images de la case (point d'interogation, etoile et bombe) - private Image interogation, etoile, imgboombe, un, deux, trois, quatre, cinq, six, sept, huit; //Constructeur de la Case public Case(){ @@ -22,19 +21,6 @@ public class Case extends JComponent{ this.bombe=false; // ce n'est pas une bombe this.voisin=0; // elle n'a pas de voisin bombe this.suspition=0; // la suspition est a 0 (pas une bombe) - - // nous chargeons les images - this.interogation= Toolkit.getDefaultToolkit().getImage("./IMAGE/pointintero.png"); - this.etoile= Toolkit.getDefaultToolkit().getImage("./IMAGE/etoile.png"); - this.imgboombe= Toolkit.getDefaultToolkit().getImage("./IMAGE/bombe.png"); - this.un=Toolkit.getDefaultToolkit().getImage("./IMAGE/un.jpg"); - this.deux=Toolkit.getDefaultToolkit().getImage("./IMAGE/deux.jpg"); - this.trois=Toolkit.getDefaultToolkit().getImage("./IMAGE/trois.jpg"); - this.quatre=Toolkit.getDefaultToolkit().getImage("./IMAGE/quatre.jpg"); - this.cinq=Toolkit.getDefaultToolkit().getImage("./IMAGE/cinq.jpg"); - this.six=Toolkit.getDefaultToolkit().getImage("./IMAGE/six.jpg"); - this.sept=Toolkit.getDefaultToolkit().getImage("./IMAGE/sept.jpg"); - this.huit=Toolkit.getDefaultToolkit().getImage("./IMAGE/huit.jpg"); } // Nous mettons les getter/setter @@ -101,12 +87,14 @@ public class Case extends JComponent{ //si on supecte que c'est une bome if(this.suspition==1){ //on affiche l'etoile - secondPinceau.drawImage(this.etoile, this.getWidth()/20*5, this.getHeight()/20*5, this.getWidth()/20*10, this.getHeight()/20*10 ,this); + Image etoile= Toolkit.getDefaultToolkit().getImage("./IMAGE/etoile.png"); + secondPinceau.drawImage(etoile, this.getWidth()/20*5, this.getHeight()/20*5, this.getWidth()/20*10, this.getHeight()/20*10 ,this); } //si on suspecte que on ne sais pas if(this.suspition==2){ + Image interogation= Toolkit.getDefaultToolkit().getImage("./IMAGE/pointintero.png"); //on affiche le point d'interogation - secondPinceau.drawImage(this.interogation, this.getWidth()/20*5, this.getHeight()/20*5, this.getWidth()/20*10, this.getHeight()/20*10 ,this); + secondPinceau.drawImage(interogation, this.getWidth()/20*5, this.getHeight()/20*5, this.getWidth()/20*10, this.getHeight()/20*10 ,this); } } //si la case est afficher(visible) @@ -116,42 +104,50 @@ public class Case extends JComponent{ secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight()); secondPinceau.setColor(new Color(255, 255, 255)); secondPinceau.fillRect(this.getWidth()/20, this.getHeight()/20, this.getWidth()/20*18, this.getHeight()/20*18); - secondPinceau.setColor(new Color(255, 0, 0)); //si la case a au moins 1 voisin qui est une bombe if(this.voisin>0){ //on ecrit le nombre de voisin que elle a if(this.voisin==1){ - secondPinceau.drawImage(this.un, this.getWidth()/20*5, this.getHeight()/20*5, this.getWidth()/20*10, this.getHeight()/20*10 ,this); + Image un=Toolkit.getDefaultToolkit().getImage("./IMAGE/un.jpg"); + secondPinceau.drawImage(un, this.getWidth()/20*5, this.getHeight()/20*5, this.getWidth()/20*10, this.getHeight()/20*10 ,this); } if(this.voisin==2){ - secondPinceau.drawImage(this.deux, this.getWidth()/20*5, this.getHeight()/20*5, this.getWidth()/20*10, this.getHeight()/20*10 ,this); + Image deux=Toolkit.getDefaultToolkit().getImage("./IMAGE/deux.jpg"); + secondPinceau.drawImage(deux, this.getWidth()/20*5, this.getHeight()/20*5, this.getWidth()/20*10, this.getHeight()/20*10 ,this); } if(this.voisin==3){ - secondPinceau.drawImage(this.trois, this.getWidth()/20*5, this.getHeight()/20*5, this.getWidth()/20*10, this.getHeight()/20*10 ,this); + Image trois=Toolkit.getDefaultToolkit().getImage("./IMAGE/trois.jpg"); + secondPinceau.drawImage(trois, this.getWidth()/20*5, this.getHeight()/20*5, this.getWidth()/20*10, this.getHeight()/20*10 ,this); } if(this.voisin==4){ - secondPinceau.drawImage(this.quatre, this.getWidth()/20*5, this.getHeight()/20*5, this.getWidth()/20*10, this.getHeight()/20*10 ,this); + Image quatre=Toolkit.getDefaultToolkit().getImage("./IMAGE/quatre.jpg"); + secondPinceau.drawImage(quatre, this.getWidth()/20*5, this.getHeight()/20*5, this.getWidth()/20*10, this.getHeight()/20*10 ,this); } if(this.voisin==5){ - secondPinceau.drawImage(this.cinq, this.getWidth()/20*5, this.getHeight()/20*5, this.getWidth()/20*10, this.getHeight()/20*10 ,this); + Image cinq=Toolkit.getDefaultToolkit().getImage("./IMAGE/cinq.jpg"); + secondPinceau.drawImage(cinq, this.getWidth()/20*5, this.getHeight()/20*5, this.getWidth()/20*10, this.getHeight()/20*10 ,this); } if(this.voisin==6){ - secondPinceau.drawImage(this.six, this.getWidth()/20*5, this.getHeight()/20*5, this.getWidth()/20*10, this.getHeight()/20*10 ,this); + Image six=Toolkit.getDefaultToolkit().getImage("./IMAGE/six.jpg"); + secondPinceau.drawImage(six, this.getWidth()/20*5, this.getHeight()/20*5, this.getWidth()/20*10, this.getHeight()/20*10 ,this); } if(this.voisin==7){ - secondPinceau.drawImage(this.sept, this.getWidth()/20*5, this.getHeight()/20*5, this.getWidth()/20*10, this.getHeight()/20*10 ,this); + Image sept=Toolkit.getDefaultToolkit().getImage("./IMAGE/sept.jpg"); + secondPinceau.drawImage(sept, this.getWidth()/20*5, this.getHeight()/20*5, this.getWidth()/20*10, this.getHeight()/20*10 ,this); } if(this.voisin==8){ - secondPinceau.drawImage(this.huit, this.getWidth()/20*5, this.getHeight()/20*5, this.getWidth()/20*10, this.getHeight()/20*10 ,this); + Image huit=Toolkit.getDefaultToolkit().getImage("./IMAGE/huit.jpg"); + secondPinceau.drawImage(huit, this.getWidth()/20*5, this.getHeight()/20*5, this.getWidth()/20*10, this.getHeight()/20*10 ,this); } } //si la case est une bombe if(this.bombe==true){ + Image imgboombe= Toolkit.getDefaultToolkit().getImage("./IMAGE/bombe.png"); //on remplace le rectangle blanc par un rectangle rouge secondPinceau.setColor(new Color(255,0,125)); secondPinceau.fillRect(this.getWidth()/20, this.getHeight()/20, this.getWidth()/20*18, this.getHeight()/20*18); //on affiche la bombe - secondPinceau.drawImage(this.imgboombe, this.getWidth()/20*5, this.getHeight()/20*5, this.getWidth()/20*10, this.getHeight()/20*10 ,this); + secondPinceau.drawImage(imgboombe, this.getWidth()/20*5, this.getHeight()/20*5, this.getWidth()/20*10, this.getHeight()/20*10 ,this); } } } diff --git a/CASE/IMAGE/lose.png b/CASE/IMAGE/lose.png index 29e6bdc..139b8c5 100644 Binary files a/CASE/IMAGE/lose.png and b/CASE/IMAGE/lose.png differ diff --git a/CASE/IMAGE/replay.png b/CASE/IMAGE/replay.png index ff643b1..0093677 100644 Binary files a/CASE/IMAGE/replay.png and b/CASE/IMAGE/replay.png differ diff --git a/CASE/IMAGE/win.png b/CASE/IMAGE/win.png index a204f95..bb8fc4b 100644 Binary files a/CASE/IMAGE/win.png and b/CASE/IMAGE/win.png differ diff --git a/CASE/Makefile b/CASE/Makefile index 705c2d8..f73b6bb 100644 --- a/CASE/Makefile +++ b/CASE/Makefile @@ -9,7 +9,8 @@ OFILES= Case.class\ plateau.class\ observateurCase.class\ paintMenuJeu.class\ - observateurSAV.class + observateurSAV.class\ + observateurFenetre.class CFLAGS= -implicit:none @@ -29,6 +30,9 @@ paintMenuJeu.class: paintMenuJeu.java observateurSAV.class: observateurSAV.java javac $(CFLAGS) observateurSAV.java +observateurFenetre.class: observateurFenetre.java + javac $(CFLAGS) observateurFenetre.java + # Chapitre 4 : Dependances main_ex.class: $(OFILES) main_ex.java diff --git a/CASE/main_ex.class b/CASE/main_ex.class index dea40f6..79c2e6f 100644 Binary files a/CASE/main_ex.class and b/CASE/main_ex.class differ diff --git a/CASE/main_ex.java b/CASE/main_ex.java index 49f1cbe..95f1710 100644 --- a/CASE/main_ex.java +++ b/CASE/main_ex.java @@ -10,9 +10,9 @@ public class main_ex{ public static void main(String[] Args){ // on initialise une fenettre JFrame fenetre = new JFrame("Démineur"); - int ligne=10; - int collonne=20; - int bombe=12; + int ligne=5; + int collonne=10; + int bombe=10; fenetre.setLocation(0,0); fenetre.setSize(1500,500); fenetre.setVisible(true); @@ -20,6 +20,6 @@ public class main_ex{ //nous utiliserons un gestionnaire GridLayout de dimensions choisi précédament plateau jeu = new plateau(fenetre); - jeu.newGame(10,20,12); + jeu.reprendrePartie(); } } \ No newline at end of file diff --git a/CASE/observateurFenetre.class b/CASE/observateurFenetre.class new file mode 100644 index 0000000..53499fa Binary files /dev/null and b/CASE/observateurFenetre.class differ diff --git a/CASE/observateurFenetre.java b/CASE/observateurFenetre.java new file mode 100644 index 0000000..23e57ac --- /dev/null +++ b/CASE/observateurFenetre.java @@ -0,0 +1,30 @@ +import java.awt.event.*; + +public class observateurFenetre implements WindowListener{ + private plateau plat; + public observateurFenetre(plateau plat0){ + this.plat=plat0; + } + + public void windowActivated(WindowEvent evenement){ + + } // premier plan + public void windowClosed(WindowEvent evenement){ + + } // après fermeture + public void windowClosing(WindowEvent evenement){ + this.plat.save(); + } // avant fermeture + public void windowDeactivated(WindowEvent evenement){ + + } // arrière-plan + public void windowDeiconified(WindowEvent evenement){ + + } // restauration + public void windowIconified(WindowEvent evenement){ + + } // minimisation + public void windowOpened(WindowEvent evenement){ + + } // après ouverture +} \ No newline at end of file diff --git a/CASE/observateurSAV.class b/CASE/observateurSAV.class index ec19f30..046d3e0 100644 Binary files a/CASE/observateurSAV.class and b/CASE/observateurSAV.class differ diff --git a/CASE/observateurSAV.java b/CASE/observateurSAV.java index bcfcfd8..5f6671a 100644 --- a/CASE/observateurSAV.java +++ b/CASE/observateurSAV.java @@ -17,7 +17,7 @@ public class observateurSAV implements MouseListener{ @Override public void mouseClicked(MouseEvent evenement){ if(this.fonction==false){ - plat.getFenetre().dispose(); + plat.save(); } if(this.fonction==true){ plat.newGame(plat.getLigne(), plat.getCollonne(), plat.getBombe()); diff --git a/CASE/paintMenuJeu.class b/CASE/paintMenuJeu.class index 1bd21b8..13992b9 100644 Binary files a/CASE/paintMenuJeu.class and b/CASE/paintMenuJeu.class differ diff --git a/CASE/paintMenuJeu.java b/CASE/paintMenuJeu.java index ab90593..c4d44ff 100644 --- a/CASE/paintMenuJeu.java +++ b/CASE/paintMenuJeu.java @@ -4,12 +4,13 @@ import javax.swing.JComponent; public class paintMenuJeu extends JComponent{ private int choix; - private int score; + private int scoreMax, score; private Image un, deux, trois, quatre, cinq, six, sept, huit, neuf, zero, err, sav, lose, win, replay; private boolean survol; public paintMenuJeu(int choix0, int score0){ this.choix=choix0; this.score=score0; + this.scoreMax=score0; this.un=Toolkit.getDefaultToolkit().getImage("./IMAGE/unD.png"); this.deux=Toolkit.getDefaultToolkit().getImage("./IMAGE/deuxD.png"); this.trois=Toolkit.getDefaultToolkit().getImage("./IMAGE/troisD.png"); @@ -42,6 +43,9 @@ public class paintMenuJeu extends JComponent{ this.survol=survol0; this.repaint(); } + public int getScoreMax(){ + return this.scoreMax; + } @Override protected void paintComponent(Graphics pinceau) { // obligatoire : on crée un nouveau pinceau pour pouvoir le modifier plus tard diff --git a/CASE/plateau.class b/CASE/plateau.class index c2439d6..ecca147 100644 Binary files a/CASE/plateau.class and b/CASE/plateau.class differ diff --git a/CASE/plateau.java b/CASE/plateau.java index f93285c..f99b3cb 100644 --- a/CASE/plateau.java +++ b/CASE/plateau.java @@ -2,9 +2,10 @@ //Class pour des fonction static de jeu //V2 - +import java.io.*; import java.util.*; import java.awt.event.*; +import java.io.ObjectOutputStream; import java.awt.*; import javax.swing.*; @@ -191,15 +192,15 @@ public class plateau{ for(int i=0; i