Changed Entity to 3d axis and added a fpstimer that calculates the fps
This commit is contained in:
parent
ec551064c4
commit
28c3cd0529
11 changed files with 222 additions and 72 deletions
58
src/ei/engine/util/FpsTimer.java
Normal file
58
src/ei/engine/util/FpsTimer.java
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package ei.engine.util;
|
||||
|
||||
import org.lwjgl.Sys;
|
||||
|
||||
/**
|
||||
* This class calculates the fps
|
||||
* @author Ziver
|
||||
*
|
||||
*/
|
||||
public class FpsTimer {
|
||||
// temp feald
|
||||
private long time;
|
||||
// The fps
|
||||
private float fps;
|
||||
|
||||
/**
|
||||
* Starts the timer
|
||||
*
|
||||
*/
|
||||
public void startTimer(){
|
||||
if(Sys.getTime() > 0){
|
||||
time = Sys.getTime();
|
||||
}
|
||||
else{
|
||||
time = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the timer and calculates the fps
|
||||
*
|
||||
*/
|
||||
public void stopTimer(){
|
||||
if(Sys.getTime() > 0){
|
||||
time = Sys.getTime() - time;
|
||||
}
|
||||
else{
|
||||
time = System.currentTimeMillis() - time;
|
||||
}
|
||||
|
||||
// calculate the fps
|
||||
fps = (float)1000/time;
|
||||
// round the fps to one decimal
|
||||
fps = (float)((int)(fps * 10))/10;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the fps
|
||||
*
|
||||
* @return The fps
|
||||
*/
|
||||
public float getFps(){
|
||||
return fps;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue