ecran de fin de victoire

This commit is contained in:
2026-03-16 16:39:57 +01:00
parent 25a9449a38
commit 805bb6583f
4 changed files with 20 additions and 1 deletions

View File

@@ -43,6 +43,7 @@ public class CampagneAutoroute {
jeu.demiCercleArriere = maVoiture; jeu.demiCercleArriere = maVoiture;
jeu.ecran.setGameOver(false); jeu.ecran.setGameOver(false);
jeu.ecran.setVictoire(false);
jeu.score = 0; jeu.score = 0;
jeu.labScore.setText("<html><h3 style='color:white;'>score : 0</h3></html>"); jeu.labScore.setText("<html><h3 style='color:white;'>score : 0</h3></html>");

View File

@@ -43,6 +43,7 @@ public class CampagneEspace {
// UI et lancement // UI et lancement
jeu.ecran.setGameOver(false); jeu.ecran.setGameOver(false);
jeu.ecran.setVictoire(false);
jeu.score = 0; jeu.score = 0;
jeu.labScore.setText("<html><h3 style='color:white;'>LUNE - score : 0</h3></html>"); jeu.labScore.setText("<html><h3 style='color:white;'>LUNE - score : 0</h3></html>");

View File

@@ -41,6 +41,7 @@ public class CampagneOcean {
jeuPrincipal.demiCercleArriere = joueur; jeuPrincipal.demiCercleArriere = joueur;
jeuPrincipal.ecran.setGameOver(false); jeuPrincipal.ecran.setGameOver(false);
jeuPrincipal.ecran.setVictoire(false);
jeuPrincipal.score = 0; jeuPrincipal.score = 0;
jeuPrincipal.labScore.setText("<html><h3 style='color:white;'>Oxygène : 0</h3></html>"); jeuPrincipal.labScore.setText("<html><h3 style='color:white;'>Oxygène : 0</h3></html>");

View File

@@ -12,6 +12,7 @@ public class ZoneDessin extends JPanel {
// Etats du jeu // Etats du jeu
protected boolean estArrete = false; protected boolean estArrete = false;
protected boolean isGameOver = false; protected boolean isGameOver = false;
protected boolean isVictoire = false;
// LE BOUTON DOIT ÊTRE PUBLIC POUR ÊTRE ACCESSIBLE DEPUIS JEU.JAVA // LE BOUTON DOIT ÊTRE PUBLIC POUR ÊTRE ACCESSIBLE DEPUIS JEU.JAVA
public JButton btnRetour; public JButton btnRetour;
@@ -38,7 +39,7 @@ public class ZoneDessin extends JPanel {
public void viderObjets() { this.listeObjets.clear(); } public void viderObjets() { this.listeObjets.clear(); }
public void traiterBoucleAnimation(){ public void traiterBoucleAnimation(){
if (estArrete || isGameOver) return; if (estArrete || isGameOver || isVictoire) return;
for (ObjetGraphique obj : listeObjets){ for (ObjetGraphique obj : listeObjets){
obj.Animer(); obj.Animer();
@@ -65,7 +66,17 @@ public class ZoneDessin extends JPanel {
String msg = "GAME OVER"; String msg = "GAME OVER";
int largeur = g2D.getFontMetrics().stringWidth(msg); int largeur = g2D.getFontMetrics().stringWidth(msg);
g2D.drawString(msg, (getWidth() - largeur) / 2, getHeight() / 2 - 50); 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) { public void setGameOver(boolean state) {
@@ -74,4 +85,9 @@ public class ZoneDessin extends JPanel {
btnRetour.setVisible(state); btnRetour.setVisible(state);
repaint(); repaint();
} }
public void setVictoire(boolean state) {
this.isVictoire = state;
btnRetour.setVisible(state);
repaint();
}
} }