dawrehxyz

gameclock

Aug 6th, 2016
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1. package com.dawreh.wickeddreams.main;
  2.  
  3. /**
  4.  * Created by Dawood on 2016-08-05.
  5.  */
  6. public class GameClock
  7. {
  8.     private long t0;
  9.     private long t1;
  10.     private long elapsedTime;
  11.     private final long nanoSecond = 1000000000;
  12.     private final long gamePlayRate = 1000000000/30;
  13.  
  14.     public long Initialize()
  15.     {
  16.         t0 = System.nanoTime();
  17.         return t0;
  18.     }
  19.  
  20.     public long CalculateElapsedTimeNS()
  21.     {
  22.         t1 = System.nanoTime();
  23.         elapsedTime = t1 - t0;
  24.         t0 = t1;
  25.         return elapsedTime;
  26.     }
  27.  
  28.     public long getGamePlayRate()
  29.     {
  30.         return gamePlayRate;
  31.     }
  32.  
  33.     public long getCurrentTime()
  34.     {
  35.         return System.nanoTime();
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment