forked from menault/TD3_DEV51_Qualite_Algo
re correction
This commit is contained in:
@@ -5,6 +5,11 @@ public class HangmanPanel extends JPanel {
|
||||
|
||||
private int errors = 0;
|
||||
|
||||
public HangmanPanel() {
|
||||
setPreferredSize(new Dimension(300, 400));
|
||||
setBackground(Color.WHITE);
|
||||
}
|
||||
|
||||
/*mettre à jour les erreurs*/
|
||||
public void setErrors(int errors) {
|
||||
this.errors = errors;
|
||||
@@ -17,22 +22,33 @@ public class HangmanPanel extends JPanel {
|
||||
|
||||
// Amélioration visuelle
|
||||
g.setColor(Color.BLACK);
|
||||
g.setFont(new Font("Arial", Font.BOLD, 12));
|
||||
g.drawString("Erreurs: " + errors + "/9", 10, 20);
|
||||
g.setFont(new Font("Arial", Font.BOLD, 16));
|
||||
g.drawString("Erreurs: " + errors + "/9", 50, 30);
|
||||
|
||||
g.drawLine(50, 300, 200, 300);
|
||||
g.drawLine(125, 300, 125, 50);
|
||||
g.drawLine(125, 50, 250, 50);
|
||||
g.drawLine(250, 50, 250, 80);
|
||||
// Dessin du pendu
|
||||
g.drawLine(50, 300, 200, 300); // Base
|
||||
g.drawLine(125, 300, 125, 50); // Poteau vertical
|
||||
g.drawLine(125, 50, 250, 50); // Poteau horizontal
|
||||
g.drawLine(250, 50, 250, 80); // Corde
|
||||
|
||||
if (errors > 0) g.drawOval(230, 80, 40, 40);
|
||||
if (errors > 1) g.drawLine(250, 120, 250, 200);
|
||||
if (errors > 2) g.drawLine(250, 140, 220, 170);
|
||||
if (errors > 3) g.drawLine(250, 140, 280, 170);
|
||||
if (errors > 4) g.drawLine(250, 200, 220, 250);
|
||||
if (errors > 5) g.drawLine(250, 200, 280, 250);
|
||||
if (errors > 6) g.drawLine(230, 90, 270, 90);
|
||||
if (errors > 7) g.drawString("X", 240, 100);
|
||||
if (errors > 8) g.drawString("X", 255, 100);
|
||||
// Parties du bonhomme
|
||||
if (errors > 0) g.drawOval(230, 80, 40, 40); // Tête
|
||||
if (errors > 1) g.drawLine(250, 120, 250, 200); // Corps
|
||||
if (errors > 2) g.drawLine(250, 140, 220, 170); // Bras gauche
|
||||
if (errors > 3) g.drawLine(250, 140, 280, 170); // Bras droit
|
||||
if (errors > 4) g.drawLine(250, 200, 220, 250); // Jambe gauche
|
||||
if (errors > 5) g.drawLine(250, 200, 280, 250); // Jambe droite
|
||||
|
||||
// VISAGE TRISTE quand il meurt :
|
||||
if (errors > 6) {
|
||||
g.drawLine(235, 95, 245, 95); // Œil gauche
|
||||
}
|
||||
if (errors > 7) {
|
||||
g.drawLine(255, 95, 265, 95); // Œil droit
|
||||
}
|
||||
if (errors > 8) {
|
||||
// Bouche TRISTE (arc vers le bas)
|
||||
g.drawArc(235, 110, 30, 15, 0, 180);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user