Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (777)
Games in Android Showcase (231)
games submitted by our members
Games in WIP (856)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
  JavaGaming.org - Pastebin



Author: hadezbladez (posted 2018-11-16 13:32:03, viewed 69 times)

1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   24   25   26   27   28   29   30   31   32   33   34   35   36   37   38   39   40   41   42   43   44   45   46   47   48   49   50   51   52   53   54   55   56   57   58   59   60   61   62   63   64   65   66   67   68   69   70   71   72   73   74   75   76   77   78   79  
void gameLoop_2(byte gups_init, boolean limit_theMultiplyDelta_init){
      //init variable
      long now = 0; long lastTime = System.nanoTime();
      double delta = 0;
      double timePerTick = 1000 * 1000 * 1000;
      double checkFPS = 0; int fps = 0, pps = 0;
      if(multiple_theTimingOfDelta == 0){this.running = false;}// << i use that game can freeze and start at anytime
      
      while(this.running){
         now = System.nanoTime();
         delta += ((now - lastTime) * gups_init / timePerTick) * multiple_theTimingOfDelta;
         checkFPS += (now - lastTime);
         lastTime = now;
         systemControls();//prerender();
         
         if(!sleeps){
            //so thread.sleeps is reducing memory consumption but it also lags the that might be the culprit but after i set it off it still cause noticable lags
                                //i guess java is being a java?
            if(delta >= 1){
               fps++;
                                        //pretty crazy in here right? this code are when game goes really wrong it will crash the game and you can modify at your will
               if(safeMethodProgramRuns == CANCER_RISK_MODE){update();render();delta--;}
               else if(safeMethodProgramRuns == SAFETY_FIRST_MODE){
                  try {update();render();delta--;}
                  catch (Exception e) {e.printStackTrace();stop(20);}
               }
               else if(safeMethodProgramRuns == SAFETY_FIRST_HANGSEC_MODE){
                  try {update();render();delta--;}
                  catch (Exception e) {
                     e.printStackTrace();
                     try {Thread.sleep(1000);}
                     catch (InterruptedException e1) {e1.printStackTrace();stop(21);}
                     stop(20);
                  }
               }
            }
            else if(delta > 2){delta = 1.9999; System.err.println("rendering errors");}
            
            if(performanceProcess == safeMemory){
               try {Thread.sleep(1);}//<<the culprit i said about
               catch (InterruptedException e) {e.printStackTrace();}
            }
            else if(performanceProcess == fullThrottle){}
            pps++;
            if(checkFPS > 1000 * 1000 * 1000){
               checkFPS -= 1000 * 1000 * 1000;
               System.out.println("fps = " + fps + " pps = " + pps);
               fps = 0; pps = 0;
            }

         }
         else if(sleeps){//now i use this because when i open windows task manager i saw CPU number that is never go to zero so i use thread.sleep and weird timings to sleep
            if(stateMusicLevel != null){
               if(!masterMusic_continueFocus && stateMusicLevel.playing() ){stateMusicLevel.pause();}
            }
            if(delta > 2){//isnt this thing wrong? dont know
               if(safeMethodProgramRuns == CANCER_RISK_MODE){delta = 1.99999;render();}
               else if(safeMethodProgramRuns == SAFETY_FIRST_MODE){
                  try {delta = 1.99999; render();}
                  catch (Exception e) {e.printStackTrace();stop(20);}
               }
               else if(safeMethodProgramRuns == SAFETY_FIRST_HANGSEC_MODE){
                  try {delta = 1.99999;render();}
                  catch (Exception e) {
                     e.printStackTrace();
                     try {Thread.sleep(1000);}
                     catch (InterruptedException e1) {e1.printStackTrace();stop(21);}
                     stop(20);
                  }
                  finally{}//<< i dont know what to do in here
               }
            }
            
            try {Thread.sleep(100);}
            catch (InterruptedException e) {e.printStackTrace();}
         }
         
         if(limit_theMultiplyDelta_init){limitMultiplyDeltaTiming();}
      }





Dump your java code here :



Special syntax:
  • To highlight a line (yellow background), prefix it with '@@'
  • To indicate that a line should be removed (red background), prefix it with '-'
  • To indicate that a line should be added (green background), prefix it with '+'
  • To post multiple snippets, seperate them by '~~~~'
  EOF
 
hadezbladez (276 views)
2018-11-16 13:46:03

hadezbladez (153 views)
2018-11-16 13:41:33

hadezbladez (286 views)
2018-11-16 13:35:35

hadezbladez (68 views)
2018-11-16 13:32:03

EgonOlsen (2123 views)
2018-06-10 19:43:48

EgonOlsen (2147 views)
2018-06-10 19:43:44

EgonOlsen (1360 views)
2018-06-10 19:43:20

DesertCoockie (1955 views)
2018-05-13 18:23:11

nelsongames (1598 views)
2018-04-24 18:15:36

nelsongames (2245 views)
2018-04-24 18:14:32
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!