SAE21_2021/Banniere.java

44 lines
1.2 KiB
Java
Raw Normal View History

2022-05-21 17:53:19 +02:00
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
2022-05-21 17:53:19 +02:00
public class Banniere extends JPanel {
2022-05-21 22:17:25 +02:00
private FrameJeu fenetre;
2022-05-21 17:53:19 +02:00
// Définition du constructeur
2022-05-21 22:17:25 +02:00
public Banniere(int mines, FrameJeu fenetre) {
2022-05-21 17:53:19 +02:00
super();
2022-05-21 22:17:25 +02:00
this.fenetre=fenetre;
2022-05-21 17:53:19 +02:00
// On défini un style à la bannière
this.setBackground( new Color(0, 236, 96));
2022-05-21 18:41:24 +02:00
2022-05-21 17:53:19 +02:00
// TODO : Bouton sauver et quitter
}
// Méthode pour afficher le nombre de mines restantes
public void setMinesLeft(int minesLeft){
this.removeAll();
this.add(new MineLeft(minesLeft,this.getSize()));
this.repaint();
2022-05-21 18:41:24 +02:00
}
// Méthode pour indiquer au joueur sa Victoire
public void setVictoire(){
this.add(new Fin("Victoire !",this.getSize()));
this.repaint();
ActionListener backToMenu = new MenuListener(this.fenetre);
Timer timerMenu = new Timer(5000, backToMenu);
timerMenu.setRepeats(false);
timerMenu.start();
2022-05-21 18:41:24 +02:00
}
// Méthode pour indiquer au joueur sa Défaite
public void setDefaite(){
this.add(new Fin("Défaite !",this.getSize()));
this.repaint();
ActionListener backToMenu = new MenuListener(this.fenetre);
Timer timerMenu = new Timer(5000, backToMenu);
timerMenu.setRepeats(false);
timerMenu.start();
2022-05-21 17:53:19 +02:00
}
}