ajout image perdu/gagner
This commit is contained in:
parent
50f6778e5f
commit
3d4c5bd4c8
BIN
CASE/IMAGE/lose.png
Normal file
BIN
CASE/IMAGE/lose.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.1 KiB |
BIN
CASE/IMAGE/win.png
Normal file
BIN
CASE/IMAGE/win.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.5 KiB |
Binary file not shown.
@ -12,7 +12,7 @@ public class main_ex{
|
||||
JFrame fenetre = new JFrame("Démineur");
|
||||
int ligne=10;
|
||||
int collonne=20;
|
||||
int bombe=30;
|
||||
int bombe=1;
|
||||
fenetre.setLocation(0,0);
|
||||
//on choisi une taille arbitraire
|
||||
|
||||
|
Binary file not shown.
@ -18,6 +18,27 @@ public class observateurCase implements MouseListener{
|
||||
}
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent evenement){
|
||||
//nous testons si le joueur a gagner/perdu
|
||||
//si perdu
|
||||
if(plateau.etatDeVictoire(this.tableau)==-1){
|
||||
plateau.removeListener(this.tableau);
|
||||
for(int i=0;i<this.tableau.length;i++){
|
||||
for(int t=0;t<this.tableau[i].length;t++){
|
||||
this.tableau[i][t].setVisibiliter(true);
|
||||
this.tableau[i][t].repaint();
|
||||
}
|
||||
}
|
||||
for(int i=0; i<tabScore.length; i++){
|
||||
tabScore[i].setChoix(5);
|
||||
}
|
||||
}
|
||||
//si gagner
|
||||
if(plateau.etatDeVictoire(this.tableau)==1){
|
||||
plateau.removeListener(this.tableau);
|
||||
for(int i=0; i<tabScore.length; i++){
|
||||
tabScore[i].setChoix(6);
|
||||
}
|
||||
}
|
||||
//si on clique gauche
|
||||
if(evenement.getButton() == MouseEvent.BUTTON1){
|
||||
//si la case n'est pas suspecter(d'etre une bombe ou je sais pas) et que elle n'est pas visible
|
||||
@ -29,16 +50,6 @@ public class observateurCase implements MouseListener{
|
||||
if(this.tableau[this.ligne][this.collonne].getVoisin()==0 && this.tableau[this.ligne][this.collonne].getBombe()==false){
|
||||
this.cliqueEvident(this.ligne, this.collonne);
|
||||
}
|
||||
//nous testons si le joueur a gagner/perdu
|
||||
int resultat=plateau.etatDeVictoire(this.tableau);
|
||||
//si il perd
|
||||
if(resultat==-1){
|
||||
plateau.perduGagner(this.tableau);
|
||||
}
|
||||
//si il gagne
|
||||
if(resultat==1){
|
||||
plateau.perduGagner(this.tableau);
|
||||
}
|
||||
}
|
||||
}
|
||||
//si clique droit
|
||||
@ -57,15 +68,6 @@ public class observateurCase implements MouseListener{
|
||||
tabScore[i].setScore(tabScore[i].getScore()+1);
|
||||
}
|
||||
}
|
||||
int resultat=plateau.etatDeVictoire(this.tableau);
|
||||
//si perdu
|
||||
if(resultat==-1){
|
||||
System.out.println("perdu");
|
||||
}
|
||||
//si gagner
|
||||
if(resultat==1){
|
||||
System.out.println("gagner");
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override // un bouton cliqué
|
||||
|
Binary file not shown.
@ -5,7 +5,7 @@ import javax.swing.JComponent;
|
||||
public class paintMenuJeu extends JComponent{
|
||||
private int choix;
|
||||
private int score;
|
||||
private Image un, deux, trois, quatre, cinq, six, sept, huit, neuf, zero, err, sav;
|
||||
private Image un, deux, trois, quatre, cinq, six, sept, huit, neuf, zero, err, sav, lose, win;
|
||||
private boolean survol;
|
||||
public paintMenuJeu(int choix0, int score0){
|
||||
this.choix=choix0;
|
||||
@ -22,6 +22,8 @@ public class paintMenuJeu extends JComponent{
|
||||
this.zero=Toolkit.getDefaultToolkit().getImage("./IMAGE/zeroD.png");
|
||||
this.err=Toolkit.getDefaultToolkit().getImage("./IMAGE/err.png");
|
||||
this.sav=Toolkit.getDefaultToolkit().getImage("./IMAGE/sav.png");
|
||||
this.lose=Toolkit.getDefaultToolkit().getImage("./IMAGE/lose.png");
|
||||
this.win=Toolkit.getDefaultToolkit().getImage("./IMAGE/win.png");
|
||||
this.survol=false;
|
||||
}
|
||||
public void setChoix(int choix0){
|
||||
@ -81,6 +83,12 @@ public class paintMenuJeu extends JComponent{
|
||||
}
|
||||
secondPinceau.drawImage(this.sav, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this);
|
||||
}
|
||||
if(this.choix==5){
|
||||
secondPinceau.drawImage(this.lose, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this);
|
||||
}
|
||||
if(this.choix==6){
|
||||
secondPinceau.drawImage(this.win, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this);
|
||||
}
|
||||
}
|
||||
private void paintNombre(Graphics secondPinceau, int nombre){
|
||||
if(this.score>=0){
|
||||
|
Binary file not shown.
@ -116,7 +116,7 @@ public class plateau{
|
||||
}
|
||||
//-----------------------------------Fonction après victoire/defaite pour enlever les observateur a chaque Case--------------------------------
|
||||
|
||||
public static void perduGagner(Case[][] tableau0){
|
||||
public static void removeListener(Case[][] tableau0){
|
||||
//on parcour le tableau du jeu
|
||||
for(int i=0; i<tableau0.length; i++){
|
||||
for(int t=0; t<tableau0[i].length; t++){
|
||||
|
Loading…
Reference in New Issue
Block a user