game over ok

This commit is contained in:
2026-02-03 15:45:52 +01:00
parent 71a2eac8b2
commit a470a08504
8 changed files with 63 additions and 46 deletions

View File

@@ -1,11 +1,6 @@
package linea;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.*;
import java.util.ArrayList;
import javax.swing.JPanel;
@@ -22,6 +17,8 @@ public class ZoneDessin extends JPanel { // hérite d'une classe du frameWork st
// un booleen qui permet d'arreter l'animation (suspendre)
protected boolean estArrete = false;
protected boolean isGameOver = false;
//-------------------------------------------------------------------------
@@ -96,9 +93,22 @@ public class ZoneDessin extends JPanel { // hérite d'une classe du frameWork st
for (ObjetGraphique obj : listeObjets){
obj.Afficher(g);
}
// à compléter
if (isGameOver) {
g2D.setColor(new Color(0, 0, 0, 150)); // Fond noir transparent
g2D.fillRect(0, 0, getWidth(), getHeight());
g2D.setColor(Color.WHITE);
g2D.setFont(new Font("Arial", Font.BOLD, 50));
String msg = "GAME OVER";
int largeurTexte = g2D.getFontMetrics().stringWidth(msg);
g2D.drawString(msg, (getWidth() - largeurTexte) / 2, getHeight() / 2);
}
}
public void setGameOver(boolean state) {
this.isGameOver = state;
repaint();
}
}