This commit is contained in:
Haïssous Kayyissa 2022-05-23 23:02:19 +02:00
parent bc345cfc93
commit a9f837eaeb
3 changed files with 22 additions and 21 deletions

View File

@ -1,6 +1,5 @@
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.*;
public class Banniere extends JPanel { public class Banniere extends JPanel {
private FrameJeu fenetre; private FrameJeu fenetre;
@ -20,26 +19,24 @@ public class Banniere extends JPanel {
// Méthode pour afficher le nombre de mines restantes // Méthode pour afficher le nombre de mines restantes
public void setMinesLeft(int minesLeft){ public void setMinesLeft(int minesLeft){
this.removeAll(); this.removeAll();
this.add(new MineLeft(minesLeft,this.getSize())); this.add(new JLabel("Mines restantes : "+Integer.toString(minesLeft)));
this.repaint(); this.repaint();
} }
// Méthode pour indiquer au joueur sa Victoire // Méthode pour indiquer au joueur sa Victoire
public void setVictoire(){ public void setVictoire(){
this.add(new Fin("Victoire !",this.getSize())); this.add(new Fin("Victoire ! Retour au menu...",this.getSize()));
this.repaint(); this.repaint();
ActionListener backToMenu = new MenuListener(this.fenetre, this.menu); Timer timerMenu = new Timer(5000, new MenuListener(this.fenetre, this.menu));
Timer timerMenu = new Timer(5000, backToMenu);
timerMenu.setRepeats(false); timerMenu.setRepeats(false);
timerMenu.start(); timerMenu.start();
} }
// Méthode pour indiquer au joueur sa Défaite // Méthode pour indiquer au joueur sa Défaite
public void setDefaite(){ public void setDefaite(){
this.add(new Fin("Défaite !",this.getSize())); this.add(new Fin("Défaite ! Retour au menu...",this.getSize()));
this.repaint(); this.repaint();
ActionListener backToMenu = new MenuListener(this.fenetre, this.menu); Timer timerMenu = new Timer(5000, new MenuListener(this.fenetre, this.menu));
Timer timerMenu = new Timer(5000, backToMenu);
timerMenu.setRepeats(false); timerMenu.setRepeats(false);
timerMenu.start(); timerMenu.start();
} }

View File

@ -15,6 +15,7 @@ public class FrameMenu extends JFrame{
private JLabel showMines; private JLabel showMines;
public FrameMenu() { public FrameMenu() {
super();
// On récupère les dimensions de l'écran pour adapter la taille de notre fenêtre // On récupère les dimensions de l'écran pour adapter la taille de notre fenêtre
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
@ -26,9 +27,15 @@ public class FrameMenu extends JFrame{
this.setLocation(screenSize.width * 3/10, screenSize.height * 1/6); this.setLocation(screenSize.width * 3/10, screenSize.height * 1/6);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(null); this.setLayout(null);
this.getContentPane().setBackground( new Color(0, 236, 96));
// Ajout du titre
JLabel titre = new JLabel("Démineur");
titre.setFont(new Font("Rockwell", Font.PLAIN, 45));
titre.setBounds((frameSize.width/3), frameSize.height/15,frameSize.width/2,frameSize.height*2/15);
this.add(titre);
// On créer les zones de textes de saisie // On créer les sliders et les JLabel qui afficheront leur valeur
this.sliderLignes = new JSlider(4,30,20); this.sliderLignes = new JSlider(4,30,20);
this.sliderColonnes = new JSlider(4,30,25); this.sliderColonnes = new JSlider(4,30,25);
this.sliderMines = new JSlider(1,900, 50); this.sliderMines = new JSlider(1,900, 50);
@ -41,9 +48,9 @@ public class FrameMenu extends JFrame{
this.colonnes=sliderColonnes.getValue(); this.colonnes=sliderColonnes.getValue();
this.mines=sliderMines.getValue(); this.mines=sliderMines.getValue();
sliderLignes.setBounds(frameSize.width*3/5, frameSize.height*6/15, frameSize.width/3, frameSize.height/20); sliderLignes.setBounds(frameSize.width/3, frameSize.height*5/15, frameSize.width/3, frameSize.height/20);
sliderColonnes.setBounds(frameSize.width*3/5, frameSize.height*8/15, frameSize.width/3, frameSize.height/20); sliderColonnes.setBounds(frameSize.width/3, frameSize.height*7/15, frameSize.width/3, frameSize.height/20);
sliderMines.setBounds(frameSize.width*3/5, frameSize.height*10/15, frameSize.width/3, frameSize.height/20); sliderMines.setBounds(frameSize.width/3, frameSize.height*9/15, frameSize.width/3, frameSize.height/20);
this.add(sliderLignes); this.add(sliderLignes);
this.add(sliderColonnes); this.add(sliderColonnes);
@ -53,9 +60,9 @@ public class FrameMenu extends JFrame{
this.showColumns= new JLabel("Colonnes : 25"); this.showColumns= new JLabel("Colonnes : 25");
this.showMines= new JLabel("Mines : 50"); this.showMines= new JLabel("Mines : 50");
this.showLines.setBounds(frameSize.width*3/5, frameSize.height*5/15, frameSize.width/3, frameSize.height/20); this.showLines.setBounds(frameSize.width/3, frameSize.height*4/15, frameSize.width/3, frameSize.height/20);
this.showColumns.setBounds(frameSize.width*3/5, frameSize.height*7/15, frameSize.width/3, frameSize.height/20); this.showColumns.setBounds(frameSize.width/3, frameSize.height*6/15, frameSize.width/3, frameSize.height/20);
this.showMines.setBounds(frameSize.width*3/5, frameSize.height*9/15, frameSize.width/3, frameSize.height/20); this.showMines.setBounds(frameSize.width/3, frameSize.height*8/15, frameSize.width/3, frameSize.height/20);
this.add(showLines); this.add(showLines);
this.add(showColumns); this.add(showColumns);
@ -64,7 +71,7 @@ public class FrameMenu extends JFrame{
JButton newGame = new JButton("Jouer"); JButton newGame = new JButton("Jouer");
newGame.addActionListener(new NewGameListener(this)); newGame.addActionListener(new NewGameListener(this));
newGame.setBounds(frameSize.width*3/5, frameSize.height*12/15, frameSize.width/5, frameSize.height/15);; newGame.setBounds(frameSize.width*10/15, frameSize.height*12/15, frameSize.width/5, frameSize.height/15);;
this.add(newGame); this.add(newGame);
JButton exit = new JButton("Quitter"); JButton exit = new JButton("Quitter");

View File

@ -26,15 +26,12 @@ FrameJeu.class : FrameJeu.java Grille.class
Grille.class : Grille.java Banniere.class Case.class Grille.class : Grille.java Banniere.class Case.class
${JC} ${JCFLAGS} Grille.java ${JC} ${JCFLAGS} Grille.java
Banniere.class : Banniere.java MineLeft.class MenuListener.class Fin.class Banniere.class : Banniere.java MenuListener.class Fin.class
${JC} ${JCFLAGS} Banniere.java ${JC} ${JCFLAGS} Banniere.java
Case.class : Case.java ListenerCase.class Entourage.class Case.class : Case.java ListenerCase.class Entourage.class
${JC} ${JCFLAGS} Case.java ${JC} ${JCFLAGS} Case.java
MineLeft.class : MineLeft.java
${JC} ${JCFLAGS} MineLeft.java
Fin.class : Fin.java Fin.class : Fin.java
${JC} ${JCFLAGS} Fin.java ${JC} ${JCFLAGS} Fin.java