ecran de fin de victoire
This commit is contained in:
@@ -12,6 +12,7 @@ public class ZoneDessin extends JPanel {
|
||||
// Etats du jeu
|
||||
protected boolean estArrete = false;
|
||||
protected boolean isGameOver = false;
|
||||
protected boolean isVictoire = false;
|
||||
|
||||
// LE BOUTON DOIT ÊTRE PUBLIC POUR ÊTRE ACCESSIBLE DEPUIS JEU.JAVA
|
||||
public JButton btnRetour;
|
||||
@@ -38,7 +39,7 @@ public class ZoneDessin extends JPanel {
|
||||
public void viderObjets() { this.listeObjets.clear(); }
|
||||
|
||||
public void traiterBoucleAnimation(){
|
||||
if (estArrete || isGameOver) return;
|
||||
if (estArrete || isGameOver || isVictoire) return;
|
||||
|
||||
for (ObjetGraphique obj : listeObjets){
|
||||
obj.Animer();
|
||||
@@ -65,7 +66,17 @@ public class ZoneDessin extends JPanel {
|
||||
String msg = "GAME OVER";
|
||||
int largeur = g2D.getFontMetrics().stringWidth(msg);
|
||||
g2D.drawString(msg, (getWidth() - largeur) / 2, getHeight() / 2 - 50);
|
||||
} else if (isVictoire) {
|
||||
g2D.setColor(new Color(0, 0, 0, 150)); // Fond sombre
|
||||
g2D.fillRect(0, 0, getWidth(), getHeight());
|
||||
|
||||
g2D.setColor(Color.GREEN);
|
||||
g2D.setFont(new Font("Arial", Font.BOLD, 50));
|
||||
String msg = "VICTOIRE";
|
||||
int largeur = g2D.getFontMetrics().stringWidth(msg);
|
||||
g2D.drawString(msg, (getWidth() - largeur) / 2, getHeight() / 2 - 50);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setGameOver(boolean state) {
|
||||
@@ -74,4 +85,9 @@ public class ZoneDessin extends JPanel {
|
||||
btnRetour.setVisible(state);
|
||||
repaint();
|
||||
}
|
||||
public void setVictoire(boolean state) {
|
||||
this.isVictoire = state;
|
||||
btnRetour.setVisible(state);
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user