public void startStop() { if (time.getStatus() != Status.STOPPED) { // if started, stop it time.stop(); lastClockTime = 0; } else { // if stopped, restart time.play(); } }
public void timer() { timer--; if (timer != 0) { clock.setText(" Time left : " + timer + " Seconds"); } if (timer == 0) { timeline.stop(); clock.setText(" Time left : " + timer + " Seconds"); check(); } }
public void stopReset() { if (time.getStatus() != Status.STOPPED) { // if started, stop it time.stop(); lastClockTime = 0; } else { // if stopped, reset it lastClockTime = 0; elapsedMillis = 0; refreshTimeDisplay(0, 0, 0); } }
public void levelUp() { level = (numberOfLines / 10) + 1; shoftDropTimer.stop(); shoftDropTimer.getKeyFrames().clear(); shoftDropTimer .getKeyFrames() .add( new KeyFrame( Duration.millis((double) 1000 * framesPerSecond[level - 1] / 60), new TimerHandler())); shoftDropTimer.play(); }
private void check() { if (checkTile(0) == true && checkTile(1) == true && checkTile(2) == true && checkTile(3) == true && checkTile(4) == true && checkTile(5) == true && checkTile(6) == true && checkTile(7) == true && checkTile(8) == true && checkTile(9) == true && checkTile(10) == true && checkTile(11) == true && checkTile(12) == true && checkTile(13) == true && checkTile(14) == true) { done = true; } if (done == true && timer != 0) { timeline.stop(); mv.setText("YOU WON !!!!!!!! IN :" + moves + " Moves"); lvl.setText("Level : " + level); iv[15].setViewport(rct[16]); sp.setText("Next"); mediaPlayer.stop(); songName = new TextField("w.mp3"); songPath = "C:\\Users\\Nihal\\Google Drive\\SCHOOL\\Java 2\\Programs\\JavaFinalProject\\src\\javafinalproject\\"; MiniMP3Player(); mediaPlayer.play(); level++; sp.setOnAction( e -> { mediaPlayer.stop(); songName = new TextField("s.mp3"); songPath = "C:\\Users\\Nihal\\Google Drive\\SCHOOL\\Java 2\\Programs\\JavaFinalProject\\src\\javafinalproject\\"; MiniMP3Player(); mediaPlayer.stop(); mediaPlayer.play(); nextGame(); }); } if (timer == 0) { lvl.setText("Level : " + level); mv.setText("Sorry You Loose, Time out!!"); } lvl.setText("Level : " + level); hc.setText("Your Score : " + ((level * 10) - 10) + " HS : " + getHS()); setHS(); }
private void stopDockRevealerTimer() { if (dockRevealer != null && dockRevealer.getStatus() == Animation.Status.RUNNING) dockRevealer.stop(); }
private void stopDockHiderTrigger() { if (dockHiderTrigger != null && dockHiderTrigger.getStatus() == Animation.Status.RUNNING) dockHiderTrigger.stop(); }
public void cancel() { myGameLoop.stop(); }
public void stopTimeline() { if (timeline != null) { timeline.stop(); timeline = null; } }
public void stop() { delayTimeline.stop(); if (secondTimeline != null) { secondTimeline.stop(); } }
private void drawMazeView(Group root) { Canvas canvas = new Canvas(800, 800); GraphicsContext gc = initialiseGraphicsContext(canvas); GridPane.setConstraints(canvas, 0, 4); GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(12); grid.setPadding(new Insets(10, 10, 10, 10)); ColumnConstraints labelConstraints = new ColumnConstraints(); labelConstraints.setMaxWidth(100); grid.getColumnConstraints().add(labelConstraints); grid.add(dimensionsLabel, 0, 0); grid.add(dimensionsTextField, 1, 0); final ComboBox mazeGenComboBox = addMazeGeneratorComboBox(); final ComboBox<String> preGenComboBox = addPreGeneratedMazeTypes(); grid.add(mazeGenComboBox, 2, 0); grid.add(preGenComboBox, 3, 0); Circle entranceMarker = new Circle(calculateTopLeftCellX(), calculateTopLeftCellY(), 5, Color.web("blue", 0.5)); root.getChildren().add(entranceMarker); Circle exitMarker = new Circle( calculateTopLeftCellX() + calculateXOffsetForExit(), calculateTopLeftCellY() + calculateYOffsetForExit(), 5, Color.web("red", 0.5)); root.getChildren().add(exitMarker); // Create button that allows you to generate a new maze Button btn = new Button(); btn.setText("Generate Maze"); btn.setOnAction( event -> { System.out.println("Button clicked!"); // default cell sizes CELL_LENGTH = 20; GAP = 5; removeBoxBlur(gc); // clear old maze root.getChildren().remove(exitMarker); timeline.stop(); timeline.getKeyFrames().clear(); gc.clearRect(0, 0, canvas.getHeight(), canvas.getWidth()); setBoxBlur(gc); String preGenSelection = preGenComboBox.getValue().toString(); if (preGenSelection.equals(DEFAULT_PRE_GEN_MAZE_TYPE)) { if (!"".equals(dimensionsTextField.getText())) { dimensions = Integer.valueOf(dimensionsTextField.getText()); try { maze = new Maze(dimensions, mazeGenComboBox.getValue().toString()); } catch (Throwable e) { e .printStackTrace(); // To change body of catch statement use File | Settings | // File Templates. } } } else if (preGenSelection.equals(MAZE_ONE)) { maze = new Maze(Maze.BT_MAZE_PROBLEM_ONE); } else if (preGenSelection.equals(MAZE_TWO)) { maze = new Maze(Maze.BT_MAZE_PROBLEM_TWO); } else if (preGenSelection.equals(MAZE_THREE)) { maze = new Maze(Maze.BT_MAZE_PROBLEM_THREE); } else if (preGenSelection.equals(MAZE_FOUR)) { maze = new Maze(Maze.BT_MAZE_PROBLEM_FOUR); } else if (preGenSelection.equals(MAZE_FIVE)) { maze = new Maze(Maze.BT_MAZE_PROBLEM_FIVE); } else if (preGenSelection.equals(MAZE_SIX)) { maze = new Maze(Maze.BRAID_MAZE_PROBLEM_ONE); } else if (preGenSelection.equals(MAZE_SEVEN)) { maze = new Maze(Maze.BRAID_MAZE_PROBLEM_TWO); } else if (preGenSelection.equals(MAZE_EIGHT)) { maze = new Maze(Maze.BRAID_MAZE_PROBLEM_THREE); } else if (preGenSelection.equals(MAZE_NINE)) { maze = new Maze(Maze.BT_MAZE_COMP); } else if (preGenSelection.equals(MAZE_TEN)) { maze = new Maze(Maze.BRAID_MAZE_COMP); } if (maze.representation().length > 24) { CELL_LENGTH = 8; GAP = 2; } drawMaze(gc); }); Button solveMazeBtn = new Button(); solveMazeBtn.setText("Solve"); solveMazeBtn.setOnAction( event -> { System.out.println("Solving maze..."); MazeSolver solver = new MazeSolver(maze.representation()); List<Path> solution; try { solution = solver.solve(); animateRoute(solution, entranceMarker, gc); efficiencyLabel.setText("Efficiency: " + solution.size() + " steps"); } catch (Throwable e) { e.printStackTrace(); } }); grid.add(btn, 0, 1); grid.add(solveMazeBtn, 2, 1); grid.add(efficiencyLabel, 3, 1); grid.add(canvas, 0, 2); root.getChildren().add(grid); }