game.time
Class CAverageTimer
java.lang.Object
game.time.CAverageTimer
public class CAverageTimer
- extends java.lang.Object
This class will take the current time, and return
an "averaged" time-slice back. It gives us better
results than simply using Java's timer at face value.
- Author:
- heavily inspired by (or riped off of) Mike Linkovich.
Constructor Summary |
CAverageTimer(float fTheoricFps,
long msTime)
|
Method Summary |
long |
getDt(long msTime)
By supplying the current time (by using System.currentTimeMillis())
we calculate the average time over the past NB_SAMPLES frames, and record
this current time to continue keeping the average accurate as possible. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NB_SAMPLES
private static final int NB_SAMPLES
- See Also:
- Constant Field Values
LIMIT_DT
private static final boolean LIMIT_DT
- See Also:
- Constant Field Values
m_tick
long[] m_tick
m_index
int m_index
m_msMaxDt
final long m_msMaxDt
CAverageTimer
public CAverageTimer(float fTheoricFps,
long msTime)
getDt
public final long getDt(long msTime)
- By supplying the current time (by using System.currentTimeMillis())
we calculate the average time over the past NB_SAMPLES frames, and record
this current time to continue keeping the average accurate as possible.
- Parameters:
msTime
- : the current time
- Returns:
- the average time over the past NB_SAMPLES frames