Esempio n. 1
0
 /**
  * Verifie qu'une pièce se situe sur le bord supérieur de la grille
  *
  * @return Vrai si une pièce est situé sur le bord supérieur de la grille, faux sinon
  */
 private boolean VerifierBordSuperieur() {
   for (int y = 0; y < Piece.GetHeight(); ++y) {
     for (int x = 0; x < Piece.GetWidth(); ++x) {
       if (this._pieceCourante.GetElementPiece(x, y) != 0
           && (y + this._yPiece) > (height - Piece.GetHeight() - 1)) {
         return true;
       }
     }
   }
   return false;
 }
Esempio n. 2
0
 private void EffacerPieceCourante() {
   for (int y = 0; y < Piece.GetHeight(); ++y) {
     for (int x = 0; x < Piece.GetWidth(); ++x) {
       if (this._pieceCourante.GetElementPiece(x, y) != 0) {
         int sumX = x + this._xPiece;
         int sumY = y + this._yPiece;
         if (!(sumX < 0 || sumX > (width - 1) || sumY < 0 || sumY > (height - 1))) {
           this._grilleJeu[x + this._xPiece][y + this._yPiece] = 0;
         }
       }
     }
   }
 }
Esempio n. 3
0
  public boolean Descendre() throws EndGameException {
    if (this._pieceCourante == null) {
      this._pieceCourante = this._pieceSuivante;
      this._pieceSuivante = Piece.GenererPieceAleatoire();
      this._xPiece = width / 2 - Piece.GetWidth() / 2;
      this._yPiece = height - Piece.GetWidth();

      EcrirePieceCourante();

      return false;
    }
    if (this._piecePose == true) {
      if (VerifierBordSuperieur() == true) {
        throw new EndGameException();
      }

      this._piecePose = false;
      DecalerLigne();
      this._pieceCourante = null;

      return false;
    }

    EffacerPieceCourante();
    if (Collision(this._pieceCourante.GetGrillePiece(), this._xPiece, this._yPiece - 1) == true) {
      EcrirePieceCourante();
      this._piecePose = true;

      return true;
    }

    --this._yPiece;
    EcrirePieceCourante();

    return false;
  }
Esempio n. 4
0
 /**
  * Renvoie vrai s'il y a une collision, faux sinon
  *
  * @param matricePiece Copie de la matrice de la pièce
  * @param newX Nouvelle position sur l'axe des abscisses de la pièce
  * @param newY Nouvelle position sur l'axe des ordonnées de la pièce
  * @return Vrai s'il y a une collision, faux sinon
  */
 public boolean Collision(int[][] matricePiece, int newX, int newY) {
   // System.out.println("Debut collision!");
   for (int y = 0; y < Piece.GetHeight(); ++y) {
     for (int x = 0; x < Piece.GetWidth(); ++x) {
       if (matricePiece[x][y] != 0) {
         int sumX = x + newX;
         int sumY = y + newY;
         if (sumX < 0 || sumX > (width - 1) || sumY < 0 || sumY > (height - 1)) {
           return true;
         }
       }
       // System.out.println((x + newX) + " : " + (y + newY));
       if (matricePiece[x][y] != 0 && this._grilleJeu[x + newX][y + newY] != 0) {
         return true;
       }
     }
   }
   // System.out.println("Fin collision!");
   return false;
 }