game.time
Class CAverageTimer

java.lang.Object
  extended by 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.

Field Summary
private static boolean LIMIT_DT
           
(package private)  int m_index
           
(package private)  long m_msMaxDt
           
(package private)  long[] m_tick
           
private static int NB_SAMPLES
           
 
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
 

Field Detail

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
Constructor Detail

CAverageTimer

public CAverageTimer(float fTheoricFps,
                     long msTime)
Method Detail

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