ajout d'un compteur de lignes supprimée et d'un bouton pour quitter l'application

This commit is contained in:
ROGER
2025-05-15 12:36:02 +02:00
parent 43037c4174
commit 309eeea534
18 changed files with 422 additions and 20 deletions

View File

@@ -10,6 +10,8 @@ public class VueControle extends JPanel {
private JPanel nextPiecePanel;
private JButton pauseButton;
private JPanel[][] caseNextPiece = new JPanel[4][4];
private JLabel nbLigneLabel;
private JButton quitterButton;
public VueControle() {
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
@@ -17,11 +19,17 @@ public class VueControle extends JPanel {
setPreferredSize(new Dimension(200, 600));
//SCORE
scoreLabel = new JLabel("Score: 0");
scoreLabel = new JLabel("SCORE : 0");
scoreLabel.setForeground(Color.white);
scoreLabel.setFont(new Font("Arial", Font.PLAIN, 16));
scoreLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
//NB LIGNE
nbLigneLabel = new JLabel("LIGNES : 0");
nbLigneLabel.setForeground(Color.white);
nbLigneLabel.setFont(new Font("Arial", Font.PLAIN, 16));
nbLigneLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
//NEXT PIECE
nextPiecePanel = new JPanel();
nextPiecePanel.setPreferredSize(new Dimension(100, 100));
@@ -30,16 +38,24 @@ public class VueControle extends JPanel {
nextPiecePanel.setAlignmentX(Component.CENTER_ALIGNMENT);
initierNextPiecePanel();
//PAUSE BUTTON
pauseButton = new JButton("Pause / Play");
pauseButton.setAlignmentX(Component.CENTER_ALIGNMENT);
//PAUSE BUTTON & QUIT BUTTON
pauseButton = new JButton("PAUSE");
quitterButton = new JButton("QUITTER");
JPanel boutonsPanel = new JPanel();
boutonsPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 10, 0));
boutonsPanel.setOpaque(false);
boutonsPanel.add(pauseButton);
boutonsPanel.add(quitterButton);
add(Box.createVerticalStrut(20)); // Add some space at the top
add(Box.createVerticalStrut(20));
add(scoreLabel);
add(Box.createVerticalStrut(20)); // Add some space between score and next piece
add(Box.createVerticalStrut(20));
add(nbLigneLabel);
add(Box.createVerticalStrut(20));
add(nextPiecePanel);
add(Box.createVerticalStrut(20)); // Add some space between next piece and button
add(pauseButton);
add(Box.createVerticalStrut(20));
add(boutonsPanel);
//setVisible(true);
}
@@ -52,6 +68,10 @@ public class VueControle extends JPanel {
return pauseButton;
}
public JButton getQuitterButton() {
return quitterButton;
}
public JPanel getNextPiecePanel() {
return nextPiecePanel;
}

View File

@@ -1,8 +1,7 @@
package org.Views;
import org.Models.Grille;
import org.Models.PieceCourante;
import org.Models.PieceL;
import org.Controlers.TetrisControleur;
import org.Models.*;
import javax.swing.*;
import java.awt.*;
@@ -13,6 +12,7 @@ public class VueTetris extends JFrame {
VueGrille vueGrille = new VueGrille(grille);
VueControle vueControle = new VueControle();
TetrisControleur controleur = new TetrisControleur(vueControle);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new BorderLayout());
@@ -25,7 +25,7 @@ public class VueTetris extends JFrame {
setVisible(true);
// Utilisation de la pièce L
PieceCourante pieceL = new PieceL();
vueControle.afficherPieceSuivante(pieceL);
PieceCourante pieceT = new PieceT();
vueControle.afficherPieceSuivante(pieceT);
}
}