Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void recompute(int[][] matrix) {
- boolean top = currRow > 0 && matrix[currRow - 1][currCol] == 0;
- boolean right = currCol < matrix[currRow].length - 1 && matrix[currRow][currCol + 1] == 0;
- boolean bottom = currRow + 1 < matrix.length - 1 && matrix[currRow + 1][currCol] == 0;
- boolean left = currCol > 0 && matrix[currRow][currCol - 1] == 0;
- if (bottom) {
- currRow++;
- } else if (top) {
- currRow--;
- } else if (left) {
- currCol--;
- } else if (right) {
- currRow++;
- }
- }
- public void redrawPath(int[][] matrix) {
- recompute(matrix);
- Timeline timeline;
- KeyFrame frame = new KeyFrame(Duration.millis(1000), e -> {
- recompute(matrix);
- }, new KeyValue(eminem.xProperty(), currCol * Constants.BLOK_SIZE),
- new KeyValue(eminem.yProperty(), currRow * Constants.BLOK_SIZE));
- timeline = new Timeline(frame);
- timeline.setCycleCount(Timeline.INDEFINITE);
- timeline.play();
- //Neighbours n = new Neighbours(top, right, bottom, left);
- //System.out.println(top + " - " + right + " " + bottom + " " + left);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement