public class collisiontest
{
public static boolean legalDown(int currentX, int currentY, int[][] board, int[][] shape)
{
int x = currentX+1;
int y = currentY;
for (int row = 0; row < 4; row++)
{
for(int col = 0; col < 4; col++)
{
if (shape[row][col] == 1 && board[x+row][y+col] == 0)
{
}
else
{
if (shape[row][col] == 0 && board[x+row][y+col] == 1)
{
}
else
{
if(shape[row][col] ==0 && board[x+row][y+row] == 0)
{
}
else
{
return false;
}
}
}
}
}
return true;
}
public static void main(String[] args)
{
int [][] m1 =
{{1,1,0,0},
{1,1,0,0},
{0,0,0,0},
{0,0,0,0},
};
int[][] board =
{{0,0,0,0},
{0,0,1,1},
{0,0,1,1},
{0,0,1,1},
{1,1,1,1},
{1,1,1,1},
{1,1,1,1},
};
int[][] board3 =
{{0,0,0,0},
{0,0,1,1},
{0,0,1,1},
{1,0,1,1},
{1,1,1,1},
{1,1,1,1},
{1,1,1,1},
};
int[][] board2 =
{{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{1,1,0,0},
};
int currentX = 1;
int currentY = 0;
System.out.println(legalDown(currentX, currentY, board, m1));
System.out.println(legalDown(currentX, currentY, board3, m1));
System.out.println(legalDown(currentX, currentY, board2, m1));
}
}