コード例 #1
0
 public void run() {
   long lastTime = System.nanoTime();
   double nsPerTick = 1000000000D / 60D;
   int ticks = 0;
   int frames = 0;
   long lastTimer = System.currentTimeMillis();
   double delta = 0.0;
   while (running) {
     long now = System.nanoTime();
     delta += (now - lastTime) / nsPerTick;
     lastTime = now;
     boolean shouldRender = false;
     while (delta >= 1) {
       ticks++;
       update();
       delta -= 1;
       shouldRender = true;
     }
     if (shouldRender) {
       frames++;
       paint(game.getWindow().getGraphics());
     }
     if (System.currentTimeMillis() - lastTimer >= 1000) {
       lastTimer += 1000;
       if (ticks >= 55 && frames >= 50) {
         RNG.extraTime();
         RNG.extraTime();
       }
       frames = 0;
       ticks = 0;
     }
   }
 }
コード例 #2
0
 public void init() {
   RNG.init();
 }
コード例 #3
0
 public GameThread(Game param) {
   game = param;
   RNG.init();
   gsm = new GameStateManager(game);
   running = true;
 }