public void run() {
    int frames = 0;
    int ticks = 0;
    long lastTime = System.nanoTime();
    //		long lastTimeFPS = System.nanoTime();
    long timer = System.currentTimeMillis();

    this.requestFocus();
    while (running) {
      long elapsed = System.nanoTime() - lastTime;
      if (elapsed >= Time.nsPerTick) {
        lastTime += Time.nsPerTick;
        Time.tickElapsed = elapsed;
        update();
        ticks++;
      }
      //			elapsed = System.nanoTime() - lastTimeFPS;
      //			if (elapsed >= Time.nsPerFrame)
      else {
        //				lastTimeFPS += Time.nsPerFrame;
        render();
        frames++;
      }

      if (System.currentTimeMillis() - timer > 1000) {
        System.out.println("FPS: " + frames + ", UPS: " + ticks);
        timer += 1000;
        frames = 0;
        ticks = 0;
      }
    }
    dispose();
  }
 private void dispose() {
   if (scene != null) scene.dispose();
   System.exit(0);
 }