-
Notifications
You must be signed in to change notification settings - Fork 1
/
Clock.java
57 lines (45 loc) · 1.09 KB
/
Clock.java
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
package helpers;
import org.lwjgl.Sys;
public class Clock {
private static boolean paused = false;
public static long lastFrame, totalTime;
public static float d = 0, multiplier = 1;
public static long getTime() {
return Sys.getTime() * 1000 / Sys.getTimerResolution();
}
public static float getDelta() {
long currentTime = getTime();
int delta = (int) (currentTime - lastFrame);
lastFrame = getTime();
return delta * 0.01f;
}
public static float Delta() {
if (paused)
return 0;
else
return d * multiplier;
}
public static float TotalTime() {
return totalTime;
}
public static float Multiplier() {
return multiplier;
}
public static void update() {
d = getDelta();
totalTime += d;
}
public static void ChangeMulti(int change){
if (multiplier + change <-1 && multiplier + change > 7){
} else {
multiplier = multiplier + change;
}
}
public static void Pause(){
if (paused){
paused = false;
} else {
paused = true;
}
}
}