Compare commits
27 Commits
master
...
64108a95e9
| Author | SHA1 | Date | |
|---|---|---|---|
| 64108a95e9 | |||
| c0d2e0e5e2 | |||
| 78333b0c32 | |||
| 5b7f341011 | |||
| 2c611bc6fd | |||
| 8b079bc103 | |||
| 790c3faff2 | |||
| 3f8a86866a | |||
| ee85d6f8f4 | |||
| d2dd0bb982 | |||
| 485b63357e | |||
| ca5c12a7ba | |||
| a7d9f17ba8 | |||
| 9b7ed446b2 | |||
| b707e37787 | |||
| 6f74af39d9 | |||
| 972ff65f63 | |||
| d74e119af3 | |||
| d79aec8248 | |||
| b4c8b1d156 | |||
| e0f727d76b | |||
| bd4a204d25 | |||
| fae2ecf2c8 | |||
| 7679f1f35b | |||
| 93e31b0aac | |||
| fd393bfc85 | |||
| 89aad809a1 |
13
Jeu_pendu/Back/Check.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package back;
|
||||
|
||||
/**
|
||||
* Vérifie la validité des entrées utilisateur.
|
||||
*/
|
||||
public class Check {
|
||||
/** Retourne vrai si la saisie est une seule lettre alphabétique */
|
||||
public static boolean isLetter(String value) {
|
||||
if (value == null) return false;
|
||||
String trimmed = value.trim();
|
||||
return trimmed.length() == 1 && Character.isLetter(trimmed.charAt(0));
|
||||
}
|
||||
}
|
||||
132
Jeu_pendu/Back/Game.java
Normal file
@@ -0,0 +1,132 @@
|
||||
package back;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Logique principale du jeu du pendu (back).
|
||||
* Ajoute un score et un chronomètre.
|
||||
*
|
||||
* Règles de score (simples) :
|
||||
* - Lettre correcte : +10 points
|
||||
* - Lettre incorrecte: -5 points (le score ne descend pas sous 0)
|
||||
* - Bonus victoire : nombre d'erreure restante sur 6 fois 10
|
||||
* - Bonus temps : Chaque seconde restante avant 60s vaut 2 points si tu met plus de 60 secondes tu n'a pas de bonus
|
||||
* - Défaite : pas de bonus
|
||||
*
|
||||
* Chronomètre :
|
||||
* - Démarre à la création de la partie
|
||||
* - S'arrête définitivement à la fin (victoire/défaite)
|
||||
*/
|
||||
public class Game {
|
||||
private final String word;
|
||||
private final Set<Character> correct = new HashSet<>();
|
||||
private final Set<Character> all = new HashSet<>();
|
||||
private final int maxErrors;
|
||||
private int errors;
|
||||
|
||||
// --- Score & chrono ---
|
||||
private int score = 0;
|
||||
private long startNano; // début de partie (System.nanoTime)
|
||||
private long endNano = -1L; // fin (sinon -1 = en cours)
|
||||
|
||||
public Game(String word, int maxErrors) {
|
||||
this.word = word.toLowerCase();
|
||||
this.maxErrors = maxErrors;
|
||||
this.startNano = System.nanoTime(); // démarre le chrono à la création
|
||||
}
|
||||
|
||||
/** Tente une lettre et renvoie le résultat + ajuste le score */
|
||||
public Result play(char letter) {
|
||||
char c = Character.toLowerCase(letter);
|
||||
if (all.contains(c)) return Result.ALREADY;
|
||||
|
||||
all.add(c);
|
||||
if (word.indexOf(c) >= 0) {
|
||||
correct.add(c);
|
||||
addScore(10);
|
||||
// Si la lettre trouvée fait gagner immédiatement, on finalise ici
|
||||
if (isWin()) end(true);
|
||||
return Result.HIT;
|
||||
} else {
|
||||
addScore(-5);
|
||||
if (isLose()) end(false);
|
||||
return Result.MISS;
|
||||
}
|
||||
}
|
||||
|
||||
/** Retourne le mot masqué avec les lettres trouvées */
|
||||
public String maskedWord() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < word.length(); i++) {
|
||||
char c = word.charAt(i);
|
||||
if (!Character.isLetter(c)) sb.append(c);
|
||||
else if (correct.contains(c)) sb.append(c);
|
||||
else sb.append('_');
|
||||
if (i < word.length() - 1) sb.append(' ');
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/** Vérifie si le joueur a gagné */
|
||||
public boolean isWin() {
|
||||
for (int i = 0; i < word.length(); i++) {
|
||||
char c = word.charAt(i);
|
||||
if (Character.isLetter(c) && !correct.contains(c)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Vérifie si le joueur a perdu */
|
||||
public boolean isLose() {
|
||||
return errors >= maxErrors;
|
||||
}
|
||||
|
||||
/** Nombre d'erreurs actuelles */
|
||||
public int getErrors() { return errors; }
|
||||
|
||||
/** Liste les lettres déjà essayées */
|
||||
public List<String> triedLetters() {
|
||||
List<Character> sorted = new ArrayList<>(all);
|
||||
sorted.sort(Character::compareTo);
|
||||
List<String> out = new ArrayList<>();
|
||||
for (Character ch : sorted) out.add(String.valueOf(ch));
|
||||
return out;
|
||||
}
|
||||
|
||||
// ---------- Score & Chrono ----------
|
||||
|
||||
/** Retourne le score courant */
|
||||
public int getScore() { return score; }
|
||||
|
||||
/** Secondes écoulées depuis le début (si finie, temps figé) */
|
||||
public long getElapsedSeconds() {
|
||||
long end = (endNano > 0L) ? endNano : System.nanoTime();
|
||||
long deltaNs = end - startNano;
|
||||
if (deltaNs < 0) deltaNs = 0;
|
||||
return deltaNs / 1_000_000_000L;
|
||||
}
|
||||
|
||||
/** Termine la partie (victoire/défaite) et applique le bonus si gagné */
|
||||
public void end(boolean win) {
|
||||
if (endNano > 0L) return; // déjà terminé
|
||||
endNano = System.nanoTime();
|
||||
if (win) {
|
||||
int remaining = Math.max(0, maxErrors - errors);
|
||||
int timeBonus = (int) Math.max(0, 60 - getElapsedSeconds()) * 2;
|
||||
addScore(remaining * 10 + timeBonus);
|
||||
}
|
||||
}
|
||||
|
||||
// --- utilitaires privés ---
|
||||
private void addScore(int delta) {
|
||||
if (delta < 0) {
|
||||
// lettre ratée => +1 erreur
|
||||
errors++;
|
||||
}
|
||||
score += delta;
|
||||
if (score < 0) score = 0;
|
||||
}
|
||||
}
|
||||
6
Jeu_pendu/Back/Result.java
Normal file
@@ -0,0 +1,6 @@
|
||||
package back;
|
||||
|
||||
/**
|
||||
* Résultat possible d'une tentative.
|
||||
*/
|
||||
public enum Result { HIT, MISS, ALREADY }
|
||||
96
Jeu_pendu/Back/Words.java
Normal file
@@ -0,0 +1,96 @@
|
||||
package back;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Fournit les mots pour le jeu.
|
||||
* - Lit d'abord "bibliothèque/mots.txt" (UTF-8), 1 mot par ligne.
|
||||
* - Ignore les lignes vides et celles qui commencent par '#'.
|
||||
* - Si le fichier est introuvable ou vide, bascule sur une liste par défaut.
|
||||
*/
|
||||
public class Words {
|
||||
|
||||
/** Chemin du fichier de mots (relatif à la racine du projet). */
|
||||
private static final Path WORDS_PATH = Paths.get("Bibliotheque", "mots.txt");
|
||||
|
||||
/** Liste de secours si le fichier n'est pas disponible. */
|
||||
private static final List<String> DEFAULT = List.of(
|
||||
"algorithm", "variable", "function", "interface", "inheritance",
|
||||
"exception", "compiler", "database", "network", "architecture",
|
||||
"iteration", "recursion", "encryption", "framework", "protocol"
|
||||
);
|
||||
|
||||
/** RNG partagé et cache des mots chargés. */
|
||||
private static final SecureRandom RNG = new SecureRandom();
|
||||
private static volatile List<String> CACHE = null;
|
||||
|
||||
/**
|
||||
* Retourne un mot choisi au hasard depuis le fichier ou la liste par défaut.
|
||||
* Déclenche un chargement paresseux (lazy-load) si nécessaire.
|
||||
*/
|
||||
public static String random() {
|
||||
ensureLoaded();
|
||||
return CACHE.get(RNG.nextInt(CACHE.size()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Recharge les mots depuis le fichier. Utile si modification de mots.txt à chaud.
|
||||
*/
|
||||
public static synchronized void reload() {
|
||||
CACHE = loadFromFileOrDefault();
|
||||
}
|
||||
|
||||
/** Garantit que le cache est initialisé. */
|
||||
private static void ensureLoaded() {
|
||||
if (CACHE == null) {
|
||||
synchronized (Words.class) {
|
||||
if (CACHE == null) {
|
||||
CACHE = loadFromFileOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Tente de charger depuis le fichier, sinon renvoie la liste par défaut. */
|
||||
private static List<String> loadFromFileOrDefault() {
|
||||
List<String> fromFile = readUtf8Lines(WORDS_PATH);
|
||||
if (fromFile.isEmpty()) return DEFAULT;
|
||||
return fromFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lit toutes les lignes UTF-8 depuis le chemin fourni,
|
||||
* en filtrant vides et commentaires (# ...).
|
||||
*/
|
||||
private static List<String> readUtf8Lines(Path path) {
|
||||
List<String> result = new ArrayList<>();
|
||||
try (Stream<String> lines = Files.lines(path, StandardCharsets.UTF_8)) {
|
||||
lines.map(String::trim)
|
||||
.filter(s -> !s.isEmpty())
|
||||
.filter(s -> !s.startsWith("#"))
|
||||
.forEach(result::add);
|
||||
} catch (IOException e) {
|
||||
// Silencieux : on basculera sur DEFAULT
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Retourne la liste complète des mots disponibles */
|
||||
public static List<String> all() {
|
||||
ensureLoaded();
|
||||
return new ArrayList<>(CACHE);
|
||||
}
|
||||
|
||||
/* Petit utilitaire pour afficher un mot masqué dans les messages */
|
||||
public static String hiddenWord(Game g) {
|
||||
return g.maskedWord().replace(' ', '_');
|
||||
}
|
||||
}
|
||||
835
Jeu_pendu/Bibliotheque/mots.txt
Normal file
62
Jeu_pendu/Front/Gallows.java
Normal file
@@ -0,0 +1,62 @@
|
||||
package front;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Gère les images du pendu (une par étape).
|
||||
* - Charge les images depuis assets
|
||||
*/
|
||||
public class Gallows {
|
||||
/** Dossier d'assets relatif à la racine du projet */
|
||||
private static final String ASSETS_DIR = "assets" + File.separator + "images";
|
||||
/** Nombre d'étapes (0 = aucun membre, 7 = étape finale) */
|
||||
private static final int MAX_STAGE = 6;
|
||||
|
||||
private static final ImageIcon[] ICONS = new ImageIcon[MAX_STAGE + 1];
|
||||
|
||||
static {
|
||||
for (int i = 0; i <= MAX_STAGE; i++) {
|
||||
String path = ASSETS_DIR + File.separator + i + ".png";
|
||||
File f = new File(path);
|
||||
if (f.exists()) {
|
||||
ICONS[i] = new ImageIcon(path);
|
||||
} else {
|
||||
// Placeholder si fichier manquant
|
||||
ICONS[i] = placeholder("Missing: " + i + ".png");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne l'icône correspondant au nombre d'erreurs.
|
||||
*/
|
||||
public static ImageIcon icon(int errors) {
|
||||
int idx = Math.max(0, Math.min(errors, MAX_STAGE));
|
||||
return ICONS[idx];
|
||||
}
|
||||
|
||||
/**
|
||||
* Crée une petite image placeholder (si un asset est manquant).
|
||||
*/
|
||||
private static ImageIcon placeholder(String text) {
|
||||
int w = 320, h = 240;
|
||||
Image img = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
|
||||
Graphics2D g = (Graphics2D) img.getGraphics();
|
||||
g.setColor(Color.LIGHT_GRAY);
|
||||
g.fillRect(0, 0, w, h);
|
||||
g.setColor(Color.DARK_GRAY);
|
||||
g.drawRect(0, 0, w - 1, h - 1);
|
||||
g.drawString(text, 10, h / 2);
|
||||
g.dispose();
|
||||
return new ImageIcon(img);
|
||||
}
|
||||
|
||||
// Import manquant pour BufferedImage
|
||||
private static class BufferedImage extends java.awt.image.BufferedImage {
|
||||
public BufferedImage(int width, int height, int imageType) {
|
||||
super(width, height, imageType);
|
||||
}
|
||||
}
|
||||
}
|
||||
190
Jeu_pendu/Front/GameUI.java
Normal file
@@ -0,0 +1,190 @@
|
||||
package front;
|
||||
|
||||
import back.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Interface graphique du jeu du pendu avec gestion des difficultés.
|
||||
* - Niveau Facile : mots de moins de 8 lettres
|
||||
* - Niveau Moyen : mots de 8 lettres ou plus
|
||||
* - Niveau Difficile : deux mots à deviner à la suite (un court + un long)
|
||||
* Toutes les méthodes ≤ 50 lignes.
|
||||
*/
|
||||
public class GameUI {
|
||||
private JFrame frame;
|
||||
private JLabel imgLabel, wordLabel, triedLabel, scoreLabel, timeLabel;
|
||||
private JTextField input;
|
||||
private JButton tryBtn, quitBtn;
|
||||
|
||||
private Game game;
|
||||
private List<String> words;
|
||||
private int index = 0;
|
||||
private int level;
|
||||
private String currentWord = "";
|
||||
private Timer timer;
|
||||
|
||||
/** Constructeur : reçoit la difficulté (1, 2 ou 3) */
|
||||
public GameUI(int level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
/** Affiche la fenêtre et lance la partie (ou séquence) */
|
||||
public void show() {
|
||||
setupWindow();
|
||||
setupLayout();
|
||||
setupActions();
|
||||
prepareWords();
|
||||
startRound();
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
/** Prépare la liste des mots selon la difficulté choisie */
|
||||
private void prepareWords() {
|
||||
words = new ArrayList<String>();
|
||||
List<String> all = Words.all();
|
||||
|
||||
if (level == 1) { // mots courts
|
||||
for (String w : all) if (w.length() < 8) words.add(w);
|
||||
} else if (level == 2) { // mots longs
|
||||
for (String w : all) if (w.length() >= 8) words.add(w);
|
||||
} else if (level == 3) { // un court + un long
|
||||
String shortW = null, longW = null;
|
||||
for (String w : all) {
|
||||
if (shortW == null && w.length() < 8) shortW = w;
|
||||
if (longW == null && w.length() >= 8) longW = w;
|
||||
if (shortW != null && longW != null) break;
|
||||
}
|
||||
if (shortW != null) words.add(shortW);
|
||||
if (longW != null) words.add(longW);
|
||||
}
|
||||
|
||||
if (words.isEmpty()) words.add(Words.random()); // fallback si rien
|
||||
}
|
||||
|
||||
/** Crée la fenêtre principale */
|
||||
private void setupWindow() {
|
||||
frame = new JFrame("Jeu du Pendu");
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setSize(560, 560);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setLayout(new BorderLayout(12, 12));
|
||||
}
|
||||
|
||||
/** Construit la mise en page et les composants */
|
||||
private void setupLayout() {
|
||||
imgLabel = new JLabel("", SwingConstants.CENTER);
|
||||
frame.add(imgLabel, BorderLayout.CENTER);
|
||||
|
||||
wordLabel = new JLabel("Mot : ");
|
||||
triedLabel = new JLabel("Lettres essayées : ");
|
||||
scoreLabel = new JLabel("Score : 0");
|
||||
timeLabel = new JLabel("Temps : 0s");
|
||||
|
||||
JPanel top = new JPanel(new GridLayout(2, 1));
|
||||
top.add(buildTopLine(wordLabel, scoreLabel));
|
||||
top.add(buildTopLine(triedLabel, timeLabel));
|
||||
frame.add(top, BorderLayout.NORTH);
|
||||
|
||||
JPanel bottom = new JPanel(new BorderLayout(8, 8));
|
||||
JPanel inputPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
input = new JTextField(5);
|
||||
tryBtn = new JButton("Essayer");
|
||||
quitBtn = new JButton("Quitter");
|
||||
inputPanel.add(new JLabel("Lettre :"));
|
||||
inputPanel.add(input);
|
||||
inputPanel.add(tryBtn);
|
||||
bottom.add(inputPanel, BorderLayout.WEST);
|
||||
bottom.add(quitBtn, BorderLayout.EAST);
|
||||
frame.add(bottom, BorderLayout.SOUTH);
|
||||
}
|
||||
|
||||
/** Construit une ligne (label gauche + espace + label droit) */
|
||||
private JPanel buildTopLine(JLabel left, JLabel right) {
|
||||
JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
p.add(left);
|
||||
p.add(Box.createHorizontalStrut(24));
|
||||
p.add(right);
|
||||
return p;
|
||||
}
|
||||
|
||||
/** Branche les actions + timer */
|
||||
private void setupActions() {
|
||||
tryBtn.addActionListener(this::onTry);
|
||||
input.addActionListener(this::onTry);
|
||||
quitBtn.addActionListener(e -> frame.dispose());
|
||||
timer = new Timer(1000, e -> refreshStatsOnly());
|
||||
}
|
||||
|
||||
/** Démarre un nouveau mot (ou termine au niveau 3) */
|
||||
private void startRound() {
|
||||
if (index >= words.size()) {
|
||||
showMsg("Niveau terminé !");
|
||||
frame.dispose();
|
||||
return;
|
||||
}
|
||||
currentWord = words.get(index++);
|
||||
game = new Game(currentWord, 7);
|
||||
input.setText("");
|
||||
input.requestFocusInWindow();
|
||||
if (!timer.isRunning()) timer.start();
|
||||
refreshUI();
|
||||
}
|
||||
|
||||
/** Tente une lettre (clic bouton ou Entrée) */
|
||||
private void onTry(ActionEvent e) {
|
||||
String text = input.getText();
|
||||
if (!Check.isLetter(text)) {
|
||||
showMsg("Tape une seule lettre (A-Z).");
|
||||
input.requestFocusInWindow();
|
||||
input.selectAll();
|
||||
return;
|
||||
}
|
||||
Result res = game.play(Character.toLowerCase(text.charAt(0)));
|
||||
if (res == Result.ALREADY) showMsg("Lettre déjà utilisée.");
|
||||
input.setText("");
|
||||
refreshUI();
|
||||
checkEnd();
|
||||
}
|
||||
|
||||
/** Vérifie la fin du mot et enchaîne si besoin (niveau 3) */
|
||||
private void checkEnd() {
|
||||
if (!(game.isWin() || game.isLose())) return;
|
||||
|
||||
timer.stop();
|
||||
game.end(game.isWin());
|
||||
String verdict = game.isWin() ? "Bravo !" : "Perdu !";
|
||||
String msg = verdict + " Le mot était : " + currentWord
|
||||
+ "\nScore : " + game.getScore()
|
||||
+ "\nTemps : " + game.getElapsedSeconds() + "s";
|
||||
showMsg(msg);
|
||||
|
||||
if (level == 3 && index < words.size()) {
|
||||
startRound();
|
||||
}
|
||||
}
|
||||
|
||||
/** Rafraîchit image + textes + stats */
|
||||
private void refreshUI() {
|
||||
imgLabel.setIcon(Gallows.icon(game.getErrors()));
|
||||
wordLabel.setText("Mot : " + game.maskedWord());
|
||||
triedLabel.setText("Lettres essayées : " + String.join(", ", game.triedLetters()));
|
||||
refreshStatsOnly();
|
||||
frame.repaint();
|
||||
}
|
||||
|
||||
/** Rafraîchit uniquement score + chrono */
|
||||
private void refreshStatsOnly() {
|
||||
scoreLabel.setText("Score : " + game.getScore());
|
||||
timeLabel.setText("Temps : " + game.getElapsedSeconds() + "s");
|
||||
}
|
||||
|
||||
/** Affiche un message */
|
||||
private void showMsg(String msg) {
|
||||
JOptionPane.showMessageDialog(frame, msg);
|
||||
}
|
||||
}
|
||||
50
Jeu_pendu/Front/MenuUI.java
Normal file
@@ -0,0 +1,50 @@
|
||||
package front;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/*
|
||||
* Menu de démarrage du jeu du pendu.
|
||||
* Permet de choisir la difficulté (facile, moyen ou difficile).
|
||||
*/
|
||||
public class MenuUI {
|
||||
private JFrame frame;
|
||||
|
||||
/**
|
||||
* Interface graphique de la page d'accueil du jeu du pendu.
|
||||
*/
|
||||
public void show() {
|
||||
frame = new JFrame("Jeu du Pendu - Sélection de la difficulté");
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setSize(400, 300);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setLayout(new BorderLayout(12, 12));
|
||||
|
||||
JLabel title = new JLabel("Choisis une difficulté", SwingConstants.CENTER);
|
||||
title.setFont(new Font("Arial", Font.BOLD, 20));
|
||||
frame.add(title, BorderLayout.NORTH);
|
||||
|
||||
JPanel buttons = new JPanel(new GridLayout(3, 1, 10, 10));
|
||||
JButton easyBtn = new JButton("Niveau Facile");
|
||||
JButton mediumBtn = new JButton("Niveau Moyen");
|
||||
JButton hardBtn = new JButton("Niveau Difficile");
|
||||
|
||||
buttons.add(easyBtn);
|
||||
buttons.add(mediumBtn);
|
||||
buttons.add(hardBtn);
|
||||
frame.add(buttons, BorderLayout.CENTER);
|
||||
|
||||
easyBtn.addActionListener(e -> startGame(1));
|
||||
mediumBtn.addActionListener(e -> startGame(2));
|
||||
hardBtn.addActionListener(e -> startGame(3));
|
||||
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
/* Lance le jeu avec le niveau choisi */
|
||||
private void startGame(int level) {
|
||||
frame.dispose(); // ferme le menu
|
||||
GameUI ui = new GameUI(level);
|
||||
ui.show();
|
||||
}
|
||||
}
|
||||
16
Jeu_pendu/Main/Main.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package main;
|
||||
|
||||
import front.MenuUI;
|
||||
|
||||
/**
|
||||
* Point d'entrée du programme.
|
||||
* Affiche le menu de sélection avant de lancer le jeu.
|
||||
*/
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
javax.swing.SwingUtilities.invokeLater(() -> {
|
||||
MenuUI menu = new MenuUI();
|
||||
menu.show();
|
||||
});
|
||||
}
|
||||
}
|
||||
BIN
Jeu_pendu/assets/images/0.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
Jeu_pendu/assets/images/1.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
Jeu_pendu/assets/images/2.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
Jeu_pendu/assets/images/3.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
Jeu_pendu/assets/images/4.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
Jeu_pendu/assets/images/5.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
Jeu_pendu/assets/images/6.png
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
27
README.md
Normal file
@@ -0,0 +1,27 @@
|
||||
- **bibliothèque/mots.txt** → liste des mots à deviner (1 par ligne)
|
||||
- **assets/images/** → images du pendu (de 0.png à 6.png)
|
||||
|
||||
---
|
||||
|
||||
## Fonctionnalités
|
||||
|
||||
Affichage d’une **image différente du pendu** à chaque erreur
|
||||
Lecture de mots depuis un **fichier externe** (`bibliothèque/mots.txt`)
|
||||
Validation des entrées (une seule LETTRE à la fois)
|
||||
Bouton **“Nouvelle partie”** pour rejouer sans relancer le programme
|
||||
Messages de victoire / défaite
|
||||
|
||||
---
|
||||
|
||||
## Compilation et exécution
|
||||
Se placer préalablement dans Jeu_pendu
|
||||
|
||||
### Compilation
|
||||
```javac -d out $(find -name "*.java")```
|
||||
|
||||
### Exécution
|
||||
```java -cp out main.Main```
|
||||
|
||||
---
|
||||
|
||||
Mini projet effectuer par Clément JANNAIRE et Clémence DUCREUX.
|
||||