Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.81 KB | None | 0 0
  1.  public boolean tryToShiftRight(int x, int y) {
  2.         int[][] gameField = model.getGameField();
  3.         int width = model.getWidth();
  4.         boolean result = false;
  5.  
  6.         if (x == width - 1) {
  7.             return false;
  8.         }
  9.         for (int j = 0; j < 4; j++) {
  10.             for (int i = 0; i < 4; i++) {
  11.                 /*if (j == 3) {
  12.                     if (positions[currPosition][i][j] == 1) {
  13.                         if (y - i >= 0 && x + j + 1 < width) {
  14.                             if (!(result = (gameField[y - i][x + j + 1] == Color.BLACK.getRGB()))) {
  15.                                 return false;
  16.                             }
  17.                         } else {
  18.                             return false;
  19.                         }
  20.                     }
  21.                 } else {
  22.                     if (positions[currPosition][i][j] == 1 && positions[currPosition][i][j + 1] == 0) {
  23.                         if (y - i >= 0 && x + j + 1 < width) {
  24.                             if (!(result = (gameField[y - i][x + j + 1] == Color.BLACK.getRGB()))) {
  25.                                 return false;
  26.                             }
  27.                         } else {
  28.                             return false;
  29.                         }
  30.                     }
  31.                 }*/
  32.                 if (positions[currPosition][i][j] == 1) {
  33.                     if (y - i >= 0 && x + j + 1 < width) {
  34.                         if (j == 3 || positions[currPosition][i][j + 1] == 0)
  35.                         if (!(result = (gameField[y - i][x + j + 1] == Color.BLACK.getRGB()))) {
  36.                             return false;
  37.                         }
  38.                     } else {
  39.                         return false;
  40.                     }
  41.                 }
  42.             }
  43.         }
  44.  
  45.         return result;
  46.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement