private void restart() { currentTrajectory = new Trajectory(ColorGenerator.getInstance().next()); gameOver = false; ball.setPosition(new Point(INITIAL_BALL_POSITION)); currentTrajectory.addPoint(ball.getPosition()); synchronized (trajectoriesLock) { trajectories.add(currentTrajectory); } renderer.getTrajectoriesTableModel().addElement(currentTrajectory); }
public void run() { currentTrajectory = new Trajectory(ColorGenerator.getInstance().next()); try { renderer.init(ball, trajectories); restart(); loop(); } catch (Exception ex) { System.out.println("An error has occured: " + ex.toString()); ex.printStackTrace(); } }
private void clearTrajectories() { synchronized (trajectoriesLock) { trajectories.clear(); } renderer.getTrajectoriesTableModel().removeAllElements(); currentTrajectory = new Trajectory(ColorGenerator.getInstance().current()); if (!gameOver) { currentTrajectory.addPoint(ball.getPosition()); synchronized (trajectoriesLock) { trajectories.add(currentTrajectory); } renderer.getTrajectoriesTableModel().addElement(currentTrajectory); } }