Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java calculate elapsedTime

deltaTime = (System.nanoTime() - lastDeltaTime) / 1_000_000_000.0D;
lastDeltaTime = System.nanoTime();
Comment

java get elapsed time

    public int fps;
    private int frames;
    private long fpsTimer;
    public double deltaTime;
    private double lastDeltaTime;
    public boolean calculatePerformance;

    public Thread thread = new Thread() {
      public void run() {
          while(running) {

              // Update, Render, etc.

              if(calculatePerformance) calculatePerformance();
          }
      }
    };

    private final void calculatePerformance() {
        frames++; // Add 1 to frames each update.
        if(System.currentTimeMillis() - fpsTimer >= 1000L) { // If 1 second has passed.
            fpsTimer = System.currentTimeMillis(); // Update timer to current time.
            fps = frames; // Set fps to frames
            frames = 0; // Reset frames
        }
        deltaTime = (System.nanoTime() - lastDeltaTime) / 1_000_000_000.0D; // Set delta time from last delta time
        lastDeltaTime = System.nanoTime(); // Set last deltaTime to current delta Time
    }
Comment

PREVIOUS NEXT
Code Example
Java :: java how to get deltaTime 
Java :: update value in hashmap java 
Java :: bukkit block place event 
Java :: fullscreen java jframe 
Java :: how to echo java_home in windows cmd 
Java :: check if map contains key java 
Java :: glide latest version android 
Java :: duck number in java 
Java :: java how to open a link 
Java :: bukkit give player effect 
Java :: clsoe keyboard android studio 
Java :: javaee .jsp get value of object with EL 
Java :: puissance java 
Java :: Integer i = new Integer(257); byte x = i.byteValue(); System.out.print(x); 
Java :: Unable to locate a Java Runtime that supports apt. 
Java :: inject in jsp 
Java :: java get amount of enums 
Java :: java convert array to another type 
Java :: java swing keyadapter 
Java :: rdd. map with condition 
Java :: convert char to string java 
Java :: spring data rest partial update 
Java :: how to byheart faster 
Java :: restart application programmatically android 
Java :: concurrent modification exception 
Java :: javafx change text size 
Java :: java check if directory exists 
Java :: hide actionbar android 
Java :: compare date with current date in android 
Java :: how to add to a date in android 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =