diff --git a/PenduWIlfried/ChooseWord.class b/PenduWIlfried/ChooseWord.class new file mode 100644 index 0000000..c692875 Binary files /dev/null and b/PenduWIlfried/ChooseWord.class differ diff --git a/PenduWIlfried/GameState.class b/PenduWIlfried/GameState.class new file mode 100644 index 0000000..0e74776 Binary files /dev/null and b/PenduWIlfried/GameState.class differ diff --git a/PenduWIlfried/GameState.java b/PenduWIlfried/GameState.java index be35125..0ee3d91 100644 --- a/PenduWIlfried/GameState.java +++ b/PenduWIlfried/GameState.java @@ -15,16 +15,35 @@ public class GameState { this.word = wordToGuess.toLowerCase(); this.difficulty = difficulty; this.hiddenWord = new char[word.length()]; - Arrays.fill(hiddenWord, '_'); + + // INITIALISATION CORRIGÉE : montrer les espaces directement + for (int i = 0; i < word.length(); i++) { + char c = word.charAt(i); + if (c == ' ') { + hiddenWord[i] = ' '; // Espace visible dès le début + } else { + hiddenWord[i] = '_'; // Lettres cachées + } + } + this.triedLetters = new HashSet<>(); this.errors = 0; this.score = 0; this.startTime = System.currentTimeMillis(); + + // Ajouter l'espace comme lettre déjà "devinée" + triedLetters.add(' '); } /*Fonction pour essayer une lettre*/ public void tryLetter(char letter) { letter = Character.toLowerCase(letter); + + // Ne pas compter l'espace comme une tentative + if (letter == ' ') { + return; + } + triedLetters.add(letter); boolean found = false; @@ -84,15 +103,15 @@ public class GameState { return difficulty; } - // Les autres méthodes restent inchangées... public boolean hasTriedLetter(char letter) { letter = Character.toLowerCase(letter); return triedLetters.contains(letter); } public boolean isWon() { - for (char c : hiddenWord) { - if (c == '_') { + for (int i = 0; i < hiddenWord.length; i++) { + // Ignorer les espaces dans la vérification + if (word.charAt(i) != ' ' && hiddenWord[i] == '_') { return false; } } diff --git a/PenduWIlfried/HangmanPanel.class b/PenduWIlfried/HangmanPanel.class new file mode 100644 index 0000000..8a59c90 Binary files /dev/null and b/PenduWIlfried/HangmanPanel.class differ diff --git a/PenduWIlfried/HangmanPanel.java b/PenduWIlfried/HangmanPanel.java index 0966c03..789ea94 100644 --- a/PenduWIlfried/HangmanPanel.java +++ b/PenduWIlfried/HangmanPanel.java @@ -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); + } } } \ No newline at end of file diff --git a/PenduWIlfried/main$1.class b/PenduWIlfried/main$1.class new file mode 100644 index 0000000..ad72706 Binary files /dev/null and b/PenduWIlfried/main$1.class differ diff --git a/PenduWIlfried/main$2.class b/PenduWIlfried/main$2.class new file mode 100644 index 0000000..977d36b Binary files /dev/null and b/PenduWIlfried/main$2.class differ diff --git a/PenduWIlfried/main$3.class b/PenduWIlfried/main$3.class new file mode 100644 index 0000000..7ea91fa Binary files /dev/null and b/PenduWIlfried/main$3.class differ diff --git a/PenduWIlfried/main.class b/PenduWIlfried/main.class new file mode 100644 index 0000000..437b1e0 Binary files /dev/null and b/PenduWIlfried/main.class differ