Exemple #1
0
 public void run() {
   PlayMusic();
   int Frames = 0;
   int Updates = 0;
   long Timer = System.currentTimeMillis();
   long lastTime = System.nanoTime();
   double Delta = 0;
   long nowTime = 0;
   final double NS = 1000000000.0 / 60;
   System.out.println("[System] Started");
   while (Running) {
     nowTime = System.nanoTime();
     Delta += (nowTime - lastTime) / NS;
     lastTime = nowTime;
     while (Delta >= 1) {
       Update();
       Updates++;
       Delta--;
     }
     Render();
     Frames++;
     if (System.currentTimeMillis() - Timer >= 1000) {
       Timer += 1000;
       Frame.setTitle(Title + "   |   " + Frames + " Fps" + "   |   " + Updates + " Updates");
       Frames = 0;
       Updates = 0;
     }
   }
   Stop();
 }
Exemple #2
0
 private void KeyUpdate() {
   Frame.requestFocus();
   KH.Update();
   if (KH.Keys[1]) Stop();
   if (KH.Keys[0]) return;
 }