コード例 #1
0
ファイル: Main.java プロジェクト: Gamefreakdm/GamesJava
 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();
 }
コード例 #2
0
ファイル: Main.java プロジェクト: Gamefreakdm/GamesJava
 private void KeyUpdate() {
   Frame.requestFocus();
   KH.Update();
   if (KH.Keys[1]) Stop();
   if (KH.Keys[0]) return;
 }