-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimer.java
More file actions
31 lines (24 loc) · 696 Bytes
/
Copy pathTimer.java
File metadata and controls
31 lines (24 loc) · 696 Bytes
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
/*
ahbejarano
Timer utility class.
Source # https://github.com/lwjglgamedev/lwjglbook/blob/master/chapter02/src/main/java/org/lwjglb/engine/Timer.java
*/
package geetransit.minecraft05.engine;
public class Timer {
private double lastLoopTime;
public void init() {
this.lastLoopTime = getTime();
}
public double getTime() {
return System.nanoTime() / 1000_000_000.0;
}
public float getElapsedTime() {
double time = getTime();
float elapsedTime = (float) (time - this.lastLoopTime);
this.lastLoopTime = time;
return elapsedTime;
}
public double getLastLoopTime() {
return this.lastLoopTime;
}
}