コード例 #1
0
 public static void main(String[] args) throws Exception {
   final BasicPhysicsEngine game = new BasicPhysicsEngine();
   final BasicView view = new BasicView(game);
   JEasyFrame frame = new JEasyFrame(view, "Basic Physics Engine");
   view.addMouseMotionListener(new BasicMouseListener());
   game.startThread(view);
 }
コード例 #2
0
  private void startThread(final BasicView view) throws InterruptedException {
    final BasicPhysicsEngine game = this;
    while (true) {
      for (int i = 0; i < NUM_EULER_UPDATES_PER_SCREEN_REFRESH; i++) {
        game.update();
      }
      view.repaint();

      try {
        Thread.sleep(DELAY);
      } catch (InterruptedException e) {
      }
    }
  }