Squashed commit of the following:

commit ab2fbeb8be52dc2886f39b72c158483793185b5c
Author: Morph01 <thibaut6969delastreet@gmail.com>
Date:   Tue May 20 15:18:20 2025 +0200

    feat: wav music file rather than mp3

commit e4ea00b4dfbe32a9a03d078a8b77c35bd934f2e6
Author: Morph01 <thibaut6969delastreet@gmail.com>
Date:   Tue May 20 14:34:34 2025 +0200

    refactor: refactor imports

commit 68ee1318f8f450f6c9358de8484c17978428949e
Author: Morph01 <thibaut6969delastreet@gmail.com>
Date:   Tue May 20 13:56:35 2025 +0200

    feat: add rotation support

commit c106cc74e351f40afbf5f03395ea14627f10b29b
Author: Morph01 <thibaut6969delastreet@gmail.com>
Date:   Tue May 20 11:44:48 2025 +0200

    fix: upper bound of generated pieces

commit 3caa2a69a49424e46078749eab53827df160af6c
Author: Morph01 <thibaut6969delastreet@gmail.com>
Date:   Tue May 20 11:40:37 2025 +0200

    Merge branch 'Gwendal' into Thibaut

commit be1fd8ddd58df1a0ab02d005ba68da154ae199c7
Author: Morph01 <thibaut6969delastreet@gmail.com>
Date:   Mon May 19 23:01:43 2025 +0200

    refactor: split in init vueGrille initialization of vueGrille rather than in constructor

commit 5ec983979b363bf671945757234047ddcc9a333e
Author: Morph01 <145839520+Morph01@users.noreply.github.com>
Date:   Mon May 19 22:47:02 2025 +0200

    refactor: better achitecture and next piece preview fixed

commit 524d96ef493c6053cfff4958697cea8583927aca
Author: Morph01 <145839520+Morph01@users.noreply.github.com>
Date:   Mon May 19 22:16:42 2025 +0200

    Squashed commit of the following:

    commit a8f543114e
    Author: ROGER <gwendal.roger@etu.univ-lyon1.fr>
    Date:   Mon May 19 21:59:38 2025 +0200

        ajout d'une fonctionnalité permettant de mettre en pause le Jeu grace à un bouton. Ajout d'un vérouillage du clavier pendant lause

    commit 27862eb3cd
    Author: ROGER <gwendal.roger@etu.univ-lyon1.fr>
    Date:   Fri May 16 17:10:15 2025 +0200

        Ajoute de l'arret de la musique en fin de partie + arret propre de l'ordonanceur

    commit 2fec9fc96e
    Author: ROGER <gwendal.roger@etu.univ-lyon1.fr>
    Date:   Fri May 16 16:17:58 2025 +0200

        integration du responsive dans l'affichage de la grille

commit 671d12f418bb6c5a0ae623e5195d78eebef4e641
Author: Morph01 <145839520+Morph01@users.noreply.github.com>
Date:   Mon May 19 22:02:16 2025 +0200

    fix: piece generation
This commit is contained in:
2025-05-20 16:10:52 +02:00
parent 4aab505eed
commit 3232cd136f
26 changed files with 409 additions and 139 deletions

View File

@@ -1,6 +1,10 @@
package org.Models;
/**
* Uniquement afin de se servir d'une paire de coordonées.
*/
import java.awt.Point;
import java.util.ArrayList;
import java.util.List;
import java.util.Observable;
@@ -189,20 +193,8 @@ public class Grille extends Observable { // TODO: ?? implements Runnable {
break;
}
for (Point caseColoree : motif) {
int newX = caseColoree.x + deltaX;
int newY = caseColoree.y + deltaY;
if (newX < 0 || newX >= nbColonnes || newY < 0 || newY >= nbLignes) {
return false;
}
if (grille[newY][newX]) {
return false;
}
}
return true;
List<Point> nouvellePosition = calculerNouvellePosition(motif, deltaX, deltaY);
return positionValide(nouvellePosition);
}
public boolean[][] getGrille() {
@@ -234,23 +226,6 @@ public class Grille extends Observable { // TODO: ?? implements Runnable {
return enPause;
}
// public void verifierEtSupprimerLignesSiBesoin() {
// for (int i = nbLignes - 1; i > 0; i--) {
// boolean ligneSupprimable = true;
// for (int j = 0; j < nbColonnes; j++) {
// if (!this.grille[i][j]) {
// ligneSupprimable = false;
// }
// }
// if (ligneSupprimable) {
// supprimerLigne(i);
// }
// }
// }
public void verifierEtSupprimerLignesSiBesoin() {
int tmpNbLignesSupprimees = 0;
System.out.println("Debut uppression d'une ligne......");
@@ -271,7 +246,7 @@ public class Grille extends Observable { // TODO: ?? implements Runnable {
tmpNbLignesSupprimees++;
}
}
System.out.println(tmpNbLignesSupprimees+ " Lignes supprimées");
System.out.println(tmpNbLignesSupprimees + " Lignes supprimées");
switch (tmpNbLignesSupprimees) {
case 1:
score += 100;
@@ -290,6 +265,22 @@ public class Grille extends Observable { // TODO: ?? implements Runnable {
}
}
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
public int getNbLignesSupprimees() {
return nbLignesSupprimees;
}
public void setNbLignesSupprimees(int nbLignesSupprimees) {
this.nbLignesSupprimees = nbLignesSupprimees;
}
// // TODO : EUHHHHHHHHHH JE CROIS PAS que ça marche comme ça c'est pas en mode
// gravité récursive, c'est juste tout descend de n lignes cassées
// // dès qu'on a fixe la pièce courante on verifie le nombre de lignes a
@@ -347,18 +338,79 @@ public class Grille extends Observable { // TODO: ?? implements Runnable {
}
}
public int getScore(){
return score;
}
public void setScore(int score) {
this.score = score;
public void tournerPiece(Orientation orientation) {
if (peuxTournerPiece(orientation)) {
boolean[][] motif = pieceCourante.getMotif();
boolean[][] nouveauMotif;
if (orientation == Orientation.SENSHORAIRE) {
nouveauMotif = PieceCourante.rotationHoraire(motif);
} else {
nouveauMotif = PieceCourante.rotationAntiHoraire(motif);
}
pieceCourante.setMotif(nouveauMotif);
setChanged();
notifyObservers();
}
}
public int getNbLignesSupprimees() {
return nbLignesSupprimees;
public boolean peuxTournerPiece(Orientation orientation) {
List<Point> positionApresRotation = calculerPositionApresRotation(orientation);
return positionValide(positionApresRotation);
}
public void setNbLignesSupprimees(int nbLignesSupprimees) {
this.nbLignesSupprimees = nbLignesSupprimees;
private List<Point> calculerPositionApresRotation(Orientation orientation) {
List<Point> nouvellePosition = new ArrayList<>();
boolean[][] motifActuel = pieceCourante.getMotif();
boolean[][] motifTourne;
boolean[][] motifCopie = new boolean[motifActuel.length][motifActuel[0].length];
for (int i = 0; i < motifActuel.length; i++) {
for (int j = 0; j < motifActuel[i].length; j++) {
motifCopie[i][j] = motifActuel[i][j];
}
}
if (orientation == Orientation.SENSHORAIRE) {
motifTourne = PieceCourante.rotationHoraire(motifCopie);
} else {
motifTourne = PieceCourante.rotationAntiHoraire(motifCopie);
}
for (int i = 0; i < motifTourne.length; i++) {
for (int j = 0; j < motifTourne[i].length; j++) {
if (motifTourne[i][j]) {
nouvellePosition.add(new Point(pieceCouranteX + j, pieceCouranteY + i));
}
}
}
return nouvellePosition;
}
public boolean positionValide(List<Point> points) {
for (Point point : points) {
if (point.x < 0 || point.x >= nbColonnes || point.y < 0 || point.y >= nbLignes) {
return false;
}
if (grille[point.y][point.x]) {
return false;
}
}
return true;
}
private List<Point> calculerNouvellePosition(List<Point> points, int deltaX, int deltaY) {
List<Point> nouvellePosPoints = new ArrayList<>();
for (Point point : points) {
nouvellePosPoints.add(new Point(point.x + deltaX, point.y + deltaY));
}
return nouvellePosPoints;
}
public void reinitialiserGrille() {
@@ -371,4 +423,5 @@ public class Grille extends Observable { // TODO: ?? implements Runnable {
setChanged();
notifyObservers();
}
}