Пример #1
0
 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);
 }
Пример #2
0
 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();
   }
 }
Пример #3
0
 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);
   }
 }