diff --git a/.gitignore b/.gitignore
index d3e245c..fc87292 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,100 @@
+# ==============================================================================
+# 1. SPECIFIQUE A TON PROJET (Ce qu'on voit sur le screenshot)
+# ==============================================================================
+# Dossiers de compilation (IntelliJ génère 'out', Eclipse génère 'bin')
out/
-/out
+bin/
+
+# Fichiers de configuration de module IntelliJ
+*.iml
+
+# Dossier de configuration projet IntelliJ
+# (On ignore tout le dossier car il contient souvent des chemins locaux spécifiques à ta machine)
+.idea/
+
+# ==============================================================================
+# 2. JAVA (Standard)
+# ==============================================================================
+# Fichiers compilés
+*.class
+
+# Archives packagées
+*.jar
+*.war
+*.nar
+*.ear
+*.zip
+*.tar.gz
+*.rar
+
+# Logs et fichiers temporaires
+*.log
+*.lock
+
+# ==============================================================================
+# 3. INTELLIJ IDEA (JetBrains) - Le "Overkill" pour être sûr
+# ==============================================================================
+# Couvre IntelliJ, PyCharm, PhpStorm, Android Studio, etc.
+*.iws
+*.ipr
+*.jwks
+.idea_modules/
+
+# ==============================================================================
+# 4. ECLIPSE
+# ==============================================================================
+.metadata
+.classpath
+.project
+.settings/
+.loadpath
+.recommenders
+.factorypath
+
+# ==============================================================================
+# 5. VISUAL STUDIO CODE
+# ==============================================================================
+.vscode/
+*.code-workspace
+.history/
+
+# ==============================================================================
+# 6. SYSTEME D'EXPLOITATION (Mac / Windows / Linux)
+# ==============================================================================
+.DS_Store
+.DS_Store?
+._*
+.Spotlight-V100
+.Trashes
+ehthumbs.db
+Thumbs.db
+.directory
+
+# ==============================================================================
+# 7. PYTHON / ANTIGRAVITY (Si jamais tu mélanges des scripts)
+# ==============================================================================
+__pycache__/
+*.py[cod]
+*$py.class
+*.so
+.Python
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+wheels/
+*.egg-info/
+.installed.cfg
+*.egg
+MANIFEST
+venv/
+.env
+.venv
+pip-log.txt
\ No newline at end of file
diff --git a/.idea/.gitignore b/.idea/.gitignore
deleted file mode 100644
index ab1f416..0000000
--- a/.idea/.gitignore
+++ /dev/null
@@ -1,10 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
-# Ignored default folder with query files
-/queries/
-# Datasource local storage ignored files
-/dataSources/
-/dataSources.local.xml
-# Editor-based HTTP Client requests
-/httpRequests/
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index a20905f..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index d7de2c6..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 35eb1dd..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/projet-dev.iml b/projet-dev.iml
deleted file mode 100644
index d851184..0000000
--- a/projet-dev.iml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Jeu.java b/src/Jeu.java
index 91af6e8..298e7ee 100644
--- a/src/Jeu.java
+++ b/src/Jeu.java
@@ -1,8 +1,6 @@
package linea;
import java.awt.Color;
-import java.awt.Cursor;
-import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@@ -11,15 +9,8 @@ import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
-import javax.swing.BorderFactory;
-import javax.swing.Box;
-import javax.swing.BoxLayout;
-import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.Timer;
@@ -56,12 +47,13 @@ public class Jeu implements KeyListener, ActionListener, MouseListener {
protected JLabel labGameOver;
protected int compteurInvincible = 0;
- // menu et fenetre
- protected JFrame fenetre;
- protected JPanel panneauMenu;
- protected JTextField champPseudo;
+ // le pseudo du joueur
protected String pseudo = "";
+ // la fenêtre et le menu principal
+ protected JFrame fenetre;
+ protected MenuPrincipal menu;
+
// -------------------------------------------------------------------------
// METHODES
// -------------------------------------------------------------------------
@@ -141,14 +133,15 @@ public class Jeu implements KeyListener, ActionListener, MouseListener {
// -------------------------------------------------------------------------
// Démarrage du jeu :
- // création de diverses instances et
+ // création de diverses instances et affichage du menu
// -------------------------------------------------------------------------
public void demarrer() {
// Création d'une fenêtre
fenetre = new JFrame("Linea");
- // on affiche le menu en premier
- afficherMenu();
+ // on crée le menu et on l'affiche en premier
+ menu = new MenuPrincipal(fenetre, this);
+ menu.afficher(pseudo);
fenetre.setSize(800, 600);
fenetre.setResizable(false);
@@ -157,111 +150,12 @@ public class Jeu implements KeyListener, ActionListener, MouseListener {
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
- private void afficherMenu() {
- panneauMenu = new JPanel();
- panneauMenu.setLayout(new BoxLayout(panneauMenu, BoxLayout.Y_AXIS));
- panneauMenu.setBackground(new Color(15, 15, 35));
- panneauMenu.setPreferredSize(new Dimension(800, 600));
-
- // espace en haut
- panneauMenu.add(Box.createVerticalStrut(80));
-
- // titre du jeu
- JLabel titre = new JLabel("LINEA");
- titre.setAlignmentX(JLabel.CENTER_ALIGNMENT);
- titre.setForeground(new Color(0, 180, 255));
- titre.setFont(new Font("Arial", Font.BOLD, 80));
- panneauMenu.add(titre);
-
- // petit sous-titre
- JLabel sousTitre = new JLabel("esquive la ligne");
- sousTitre.setAlignmentX(JLabel.CENTER_ALIGNMENT);
- sousTitre.setForeground(new Color(120, 120, 160));
- sousTitre.setFont(new Font("Arial", Font.PLAIN, 18));
- panneauMenu.add(sousTitre);
-
- panneauMenu.add(Box.createVerticalStrut(40));
-
- // label pseudo
- JLabel labPseudo = new JLabel("pseudo");
- labPseudo.setAlignmentX(JLabel.CENTER_ALIGNMENT);
- labPseudo.setForeground(new Color(180, 180, 200));
- labPseudo.setFont(new Font("Arial", Font.PLAIN, 14));
- panneauMenu.add(labPseudo);
-
- panneauMenu.add(Box.createVerticalStrut(8));
-
- // champ de texte pour le pseudo
- champPseudo = new JTextField(15);
- champPseudo.setText(pseudo); // garde le pseudo prérempli s'il y en a un
- champPseudo.setMaximumSize(new Dimension(250, 40));
- champPseudo.setFont(new Font("Arial", Font.PLAIN, 16));
- champPseudo.setHorizontalAlignment(JTextField.CENTER);
- champPseudo.setBackground(new Color(30, 30, 60));
- champPseudo.setForeground(Color.WHITE);
- champPseudo.setCaretColor(Color.WHITE);
- champPseudo.setBorder(BorderFactory.createLineBorder(new Color(0, 180, 255), 2, true));
- champPseudo.setAlignmentX(JTextField.CENTER_ALIGNMENT);
- panneauMenu.add(champPseudo);
-
- panneauMenu.add(Box.createVerticalStrut(40));
-
- // bouton jouer
- JButton boutonJouer = new JButton("JOUER");
- styleBouton(boutonJouer, new Color(0, 130, 255));
- boutonJouer.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- lancerPartie();
- }
- });
- panneauMenu.add(boutonJouer);
-
- panneauMenu.add(Box.createVerticalStrut(15));
-
- // bouton classement
- JButton boutonClassement = new JButton("CLASSEMENT");
- styleBouton(boutonClassement, new Color(100, 100, 150));
- boutonClassement.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- JOptionPane.showMessageDialog(fenetre, "TOP SCORES", "Classement", JOptionPane.INFORMATION_MESSAGE);
- }
- });
- panneauMenu.add(boutonClassement);
-
- panneauMenu.add(Box.createVerticalStrut(15));
-
- // bouton quitter
- JButton boutonQuitter = new JButton("QUITTER");
- styleBouton(boutonQuitter, new Color(200, 50, 50));
- boutonQuitter.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- System.exit(0);
- }
- });
- panneauMenu.add(boutonQuitter);
-
- fenetre.setContentPane(panneauMenu);
- fenetre.revalidate();
- fenetre.repaint();
- }
-
- private void styleBouton(JButton btn, Color fond) {
- btn.setAlignmentX(JButton.CENTER_ALIGNMENT);
- btn.setFont(new Font("Arial", Font.BOLD, 18));
- btn.setForeground(Color.WHITE);
- btn.setBackground(fond);
- btn.setFocusPainted(false);
- btn.setBorderPainted(false);
- btn.setCursor(new Cursor(Cursor.HAND_CURSOR));
- btn.setMaximumSize(new Dimension(200, 45));
- }
-
- private void lancerPartie() {
- // on recupere le pseudo
- pseudo = champPseudo.getText();
+ // -------------------------------------------------------------------------
+ // Lance une nouvelle partie (appelé par le MenuPrincipal)
+ // -------------------------------------------------------------------------
+ public void lancerPartie(String pseudoSaisi) {
+ // on récupère le pseudo
+ pseudo = pseudoSaisi;
// A FAIRE :
// placer dans l'instance de l'écran tous les objets graphiques nécessaires
@@ -347,6 +241,9 @@ public class Jeu implements KeyListener, ActionListener, MouseListener {
demiCercleAvant.ResterDansLigne(lili);
}
+ // -------------------------------------------------------------------------
+ // Retour au menu principal (après un game over)
+ // -------------------------------------------------------------------------
private void retourMenu() {
// on arrete le timer du jeu
if (horloge != null) {
@@ -364,7 +261,7 @@ public class Jeu implements KeyListener, ActionListener, MouseListener {
ecran.viderObjets();
// on retourne au menu principal
- afficherMenu();
+ menu.afficher(pseudo);
}
// -------------------------------------------------------------------------
diff --git a/src/MenuPrincipal.java b/src/MenuPrincipal.java
new file mode 100644
index 0000000..807e856
--- /dev/null
+++ b/src/MenuPrincipal.java
@@ -0,0 +1,75 @@
+package linea;
+
+import java.awt.FlowLayout;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+import javax.swing.SwingConstants;
+
+// Classe qui représente le menu principal du jeu (affiché au lancement).
+public class MenuPrincipal {
+
+ private JFrame fenetre;
+ private Jeu jeu;
+ private JTextField champPseudo;
+
+ public MenuPrincipal(JFrame fenetre, Jeu jeu) {
+ this.fenetre = fenetre;
+ this.jeu = jeu;
+ }
+
+ // Construit et affiche le panneau du menu dans la fenêtre
+ public void afficher(String pseudoActuel) {
+
+ JPanel panneau = new JPanel(new GridLayout(6, 1, 10, 10));
+
+ JLabel titre = new JLabel("LINEA", SwingConstants.CENTER);
+ champPseudo = new JTextField(pseudoActuel, 15);
+
+ JButton boutonJouer = new JButton("Jouer");
+ JButton boutonClassement = new JButton("Classement");
+ JButton boutonQuitter = new JButton("Quitter");
+
+ boutonJouer.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ jeu.lancerPartie(champPseudo.getText());
+ }
+ });
+
+ boutonClassement.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ JOptionPane.showMessageDialog(fenetre, "TOP SCORES", "Classement", JOptionPane.INFORMATION_MESSAGE);
+ }
+ });
+
+ boutonQuitter.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ System.exit(0);
+ }
+ });
+
+ panneau.add(titre);
+ panneau.add(champPseudo);
+ panneau.add(boutonJouer);
+ panneau.add(boutonClassement);
+ panneau.add(boutonQuitter);
+
+ // panneau centré dans la fenêtre
+ JPanel conteneur = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 150));
+ conteneur.add(panneau);
+
+ fenetre.setContentPane(conteneur);
+ fenetre.revalidate();
+ fenetre.repaint();
+ }
+}