diff --git a/bin/com/charpentierbalocchi/dorfjavatik/resources/image.gif b/bin/com/charpentierbalocchi/dorfjavatik/resources/image.gif deleted file mode 100644 index d7084e6..0000000 Binary files a/bin/com/charpentierbalocchi/dorfjavatik/resources/image.gif and /dev/null differ diff --git a/makefile b/makefile new file mode 100644 index 0000000..7ac4129 --- /dev/null +++ b/makefile @@ -0,0 +1,47 @@ +# Variables +JAVAC = javac +JAR = jar +SRC_DIR = src +BIN_DIR = bin +MANIFEST = MANIFEST.MF +MAIN_CLASS = com.charpentierbalocchi.dorfjavatik.view.FenetreDemarrage +JAR_FILE = DorfJavaTik.jar +RESOURCES_DIR = src/com/charpentierbalocchi/dorfjavatik/resources +RESOURCES_BIN_DIR = bin/com/charpentierbalocchi/dorfjavatik/resources + +# Règles +.PHONY: all clean jar run + +all: classes + +# Compilation des fichiers .class +classes: + @echo "Compilation des fichiers .java en .class..." + @mkdir -p $(BIN_DIR) + $(JAVAC) -d $(BIN_DIR) -encoding UTF-8 $(shell find $(SRC_DIR) -name "*.java") + @echo "Compilation terminée." + +# Création du fichier JAR +jar: classes + @echo "Copie des ressources..." + @mkdir -p $(RESOURCES_BIN_DIR) + @cp -r $(RESOURCES_DIR)/* $(RESOURCES_BIN_DIR) + @echo "Création du fichier JAR..." + $(JAR) cfm $(JAR_FILE) $(MANIFEST) -C $(BIN_DIR) . + @echo "Fichier JAR créé : $(JAR_FILE)" + +# Nettoyage des fichiers compilés et du JAR +clean: + @echo "Nettoyage des fichiers compilés..." + @rm -rf $(BIN_DIR)/* + @rm -f $(JAR_FILE) + @echo "Nettoyage terminé." + +# Exécution du fichier JAR +run: jar + @echo "Exécution du fichier JAR..." + @java -jar $(JAR_FILE) + +# Crée le fichier MANIFEST.MF avec la classe principale +manifest: + @echo "Main-Class: $(MAIN_CLASS)" > $(MANIFEST) diff --git a/src/com/charpentierbalocchi/dorfjavatik/controller/ControleurJeu.java b/src/com/charpentierbalocchi/dorfjavatik/controller/ControleurJeu.java index 0d92e9d..3d7f13c 100644 --- a/src/com/charpentierbalocchi/dorfjavatik/controller/ControleurJeu.java +++ b/src/com/charpentierbalocchi/dorfjavatik/controller/ControleurJeu.java @@ -31,6 +31,7 @@ public class ControleurJeu { Tuile tuileCourante = fenetreJeu.getTuileCourante(); if (tuileCourante != null && plateau.placerTuile(tuileCourante, x, y)) { int score = plateau.calculerScore(x, y, tuileCourante); + fenetreJeu.setScore(score); fenetreJeu.setScore(plateau.getScore()); fenetreJeu.updateBoard(x, y, tuileCourante); if (plateauEstComplet()) { diff --git a/src/com/charpentierbalocchi/dorfjavatik/resources/background.wav b/src/com/charpentierbalocchi/dorfjavatik/resources/background.wav new file mode 100644 index 0000000..060b566 Binary files /dev/null and b/src/com/charpentierbalocchi/dorfjavatik/resources/background.wav differ diff --git a/src/com/charpentierbalocchi/dorfjavatik/view/FenetreDemarrage.java b/src/com/charpentierbalocchi/dorfjavatik/view/FenetreDemarrage.java index 4118908..ac1e391 100644 --- a/src/com/charpentierbalocchi/dorfjavatik/view/FenetreDemarrage.java +++ b/src/com/charpentierbalocchi/dorfjavatik/view/FenetreDemarrage.java @@ -38,10 +38,8 @@ public class FenetreDemarrage extends JFrame { try { int taille = Integer.parseInt(textField.getText()); if (taille == 1) { - // Charger le GIF à partir du chemin de fichier - String gifPath = "bin/com/charpentierbalocchi/dorfjavatik/resources/image.gif"; // Remplacer par - // le chemin - // correct + String gifPath = "src/com/charpentierbalocchi/dorfjavatik/resources/image.gif"; + ImageIcon gifIcon = new ImageIcon(gifPath); // Vérifier si le GIF est chargé correctement @@ -74,7 +72,8 @@ public class FenetreDemarrage extends JFrame { new FenetreJeu(taille); dispose(); } else { - JOptionPane.showMessageDialog(null, "Veuillez entrer une taille de grille entre 1 et 15.", + JOptionPane.showMessageDialog(null, + "Veuillez entrer une taille de grille comprise entre 1 et 15.", "Erreur", JOptionPane.ERROR_MESSAGE); } } catch (NumberFormatException ex) { diff --git a/src/com/charpentierbalocchi/dorfjavatik/view/FenetreJeu.java b/src/com/charpentierbalocchi/dorfjavatik/view/FenetreJeu.java index d4eccb6..be09e35 100644 --- a/src/com/charpentierbalocchi/dorfjavatik/view/FenetreJeu.java +++ b/src/com/charpentierbalocchi/dorfjavatik/view/FenetreJeu.java @@ -15,6 +15,11 @@ public class FenetreJeu extends JFrame { private int taillePlateau; // Taille du plateau private TileButton[][] boutons; // Boutons représentant les cases du plateau private JLabel labelScore; // Label pour afficher le score + private JLabel labelBiome1; // Label pour afficher le biome 1 + private JLabel labelBiome2; // Label pour afficher le biome 2 + private JLabel labelBiome3; // Label pour afficher le biome 3 + private JLabel labelBiome4; // Label pour afficher le biome 4 + private JLabel labelBiome5; // Label pour afficher le biome 5 private Tuile tuileCourante; // La tuile actuellement proposée private ControleurJeu controleurJeu; // Instance du contrôleur de jeu private JPanel panelPlateau; // Panneau pour le plateau de jeu @@ -22,7 +27,7 @@ public class FenetreJeu extends JFrame { private MusicPlayer musicPlayer; // Instance du lecteur de musique public FenetreJeu(int taillePlateau) { - super("DorfJavaTik"); // Titre de la fenêtre + super("DorfJavaTik, par Juliette et Loris"); // Titre de la fenêtre this.taillePlateau = taillePlateau; initUI(); this.controleurJeu = new ControleurJeu(this, taillePlateau); // Initialiser le contrôleur après la configuration @@ -33,7 +38,7 @@ public class FenetreJeu extends JFrame { setLocationRelativeTo(null); // Centre la fenêtre sur l'écran setVisible(true); // Rendre la fenêtre visible // Démarrer la musique de fond - musicPlayer = new MusicPlayer("/com/charpentierbalocchi/dorfjavatik/resources/PleasantHill.wav"); + musicPlayer = new MusicPlayer("/com/charpentierbalocchi/dorfjavatik/resources/background.wav"); musicPlayer.play(); } @@ -51,7 +56,6 @@ public class FenetreJeu extends JFrame { final int y = j; bouton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - // Logique de placement d'une tuile controleurJeu.handleTilePlacement(x, y); } }); @@ -64,11 +68,31 @@ public class FenetreJeu extends JFrame { // verticalement JPanel panelGauche = new JPanel(); panelGauche.setLayout(new BoxLayout(panelGauche, BoxLayout.Y_AXIS)); - panelGauche.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); + panelGauche.setBorder(BorderFactory.createEmptyBorder(20, 60, 20, 60)); labelScore = new JLabel("Score: 0"); labelScore.setAlignmentX(Component.CENTER_ALIGNMENT); - labelScore.setFont(new Font("Serif", Font.BOLD, 24)); // Définir la police plus grande pour le score + labelScore.setFont(new Font("Serif", Font.BOLD, 24)); + + labelBiome1 = new JLabel("Rivières & Lacs : BLEU"); + labelBiome1.setAlignmentX(Component.CENTER_ALIGNMENT); + labelBiome1.setFont(new Font("Serif", Font.PLAIN, 18)); + + labelBiome2 = new JLabel("Forêts : VERT"); + labelBiome2.setAlignmentX(Component.CENTER_ALIGNMENT); + labelBiome2.setFont(new Font("Serif", Font.PLAIN, 18)); + + labelBiome3 = new JLabel("Champs : JAUNE"); + labelBiome3.setAlignmentX(Component.CENTER_ALIGNMENT); + labelBiome3.setFont(new Font("Serif", Font.PLAIN, 18)); + + labelBiome4 = new JLabel("Villages : ROUGE"); + labelBiome4.setAlignmentX(Component.CENTER_ALIGNMENT); + labelBiome4.setFont(new Font("Serif", Font.PLAIN, 18)); + + labelBiome5 = new JLabel("Montagnes : GRIS"); + labelBiome5.setAlignmentX(Component.CENTER_ALIGNMENT); + labelBiome5.setFont(new Font("Serif", Font.PLAIN, 18)); panelTuileCourante = new JPanel() { @Override @@ -91,15 +115,29 @@ public class FenetreJeu extends JFrame { controleurJeu.demarrerJeu(); } }); + JButton boutonQuitter = new JButton("Quitter"); + boutonQuitter.setAlignmentX(Component.CENTER_ALIGNMENT); + boutonQuitter.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + System.exit(0); + } + }); panelGauche.add(Box.createVerticalGlue()); panelGauche.add(labelScore); panelGauche.add(Box.createVerticalStrut(20)); // Espace entre les composants panelGauche.add(panelTuileCourante); - panelGauche.add(Box.createVerticalStrut(20)); // Espace entre les composants + panelGauche.add(Box.createVerticalStrut(20)); panelGauche.add(boutonRecommencer); + panelGauche.add(boutonQuitter); panelGauche.add(Box.createVerticalGlue()); + panelGauche.add(labelBiome1); + panelGauche.add(labelBiome2); + panelGauche.add(labelBiome3); + panelGauche.add(labelBiome4); + panelGauche.add(labelBiome5); + panelPrincipal.add(panelGauche, BorderLayout.WEST); panelPrincipal.add(panelPlateau, BorderLayout.CENTER);