Advertisement
Guest User

Clock class

a guest
Oct 21st, 2014
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. package helpers;
  2.  
  3. import org.lwjgl.Sys;
  4.  
  5. public class Clock {
  6.  
  7. public static boolean paused = false;
  8. public static long LastFrame, totalTime;
  9. public static float d = 0, multiplier = 1;
  10.  
  11. public static long getTime() {
  12. return Sys.getTime() * 1000 / Sys.getTimerResolution();
  13. }
  14.  
  15. public static float getDelta() {
  16. long currentTime = getTime();
  17. int delta = (int) (currentTime - LastFrame);
  18. LastFrame = getTime();
  19. return delta * 0.01f;
  20. }
  21.  
  22. public static float Delta() {
  23. if (paused)
  24. return 0;
  25. else
  26. return d * multiplier;
  27. }
  28.  
  29. public static float TotalTime() {
  30. return totalTime;
  31. }
  32.  
  33. public static float Multiplier() {
  34. return multiplier;
  35. }
  36.  
  37. public static void update() {
  38. d = getDelta();
  39. totalTime += d;
  40. }
  41.  
  42. public static void changeMultiplier(int change) {
  43. if (multiplier + change < -1 && multiplier + change > 7) {
  44.  
  45. }else{
  46. multiplier += change;
  47. }
  48. }
  49. public static void Pause() {
  50. if (paused){
  51. paused = false;
  52. }else{
  53. paused = true;
  54. }
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement