feat: init VueGrille

This commit is contained in:
Morph01
2025-05-13 12:01:57 +02:00
parent b2649c364b
commit 5a175ea4b4
12 changed files with 125 additions and 2 deletions

View File

@@ -3,6 +3,9 @@
*/
package org;
import org.Models.Grille;
import org.Views.VueGrille;
public class App {
public String getGreeting() {
return "Hello World!";
@@ -10,5 +13,7 @@ public class App {
public static void main(String[] args) {
System.out.println(new App().getGreeting());
Grille grille = new Grille(10, 10);
VueGrille vueGrille = new VueGrille(grille);
}
}
}

View File

@@ -0,0 +1,21 @@
package org.Models;
public class Grille {
private boolean[][] grille;
public int nbLignes;
public int nbColonnes;
public Grille(int nbLignes, int nbColonnes) {
this.nbLignes = nbLignes;
this.nbColonnes = nbColonnes;
this.grille = new boolean[nbLignes][nbColonnes];
}
public int getNbLignes() {
return nbLignes;
}
public int getNbColonnes() {
return nbColonnes;
}
}

View File

@@ -0,0 +1,5 @@
package org.Models;
public class Jeu {
}

View File

@@ -0,0 +1,5 @@
package org.Models;
public class PieceCourante {
}

View File

@@ -0,0 +1,5 @@
package org.Models;
public class PieceL {
}

View File

@@ -0,0 +1,41 @@
package org.Views;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.Border;
import org.Models.Grille;
import java.awt.Color;
import java.awt.GridLayout;
public class VueGrille extends JFrame {
private JPanel grillePanel;
private int tailleJPanel = 1000;
private Grille grille;
public VueGrille(Grille grille) {
this.grille = grille;
grillePanel = new JPanel(new GridLayout(grille.getNbLignes(), grille.getNbColonnes()));
setSize(tailleJPanel, tailleJPanel);
setContentPane(grillePanel);
initialiserVueGrille();
}
private void initialiserVueGrille() {
Border border = BorderFactory.createLineBorder(Color.BLACK);
for (int i = 0; i < grille.getNbLignes(); i++) {
for (int j = 0; j < grille.getNbColonnes(); j++) {
JPanel caseG = new JPanel();
caseG.setBorder(border);
caseG.setBackground(Color.WHITE);
grillePanel.add(caseG);
}
}
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setTitle("TETRIS");
}
}