Package gaiasky.util.time
Class GlobalClock
java.lang.Object
gaiasky.util.time.GlobalClock
- All Implemented Interfaces:
IObserver,ITimeFrameProvider
Keeps pace of the simulation time vs real time and holds the global clock. It
uses a time warp factor which is a multiplier to real time.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoublegetDt()The frame time difference in seconds.floatReturns the fixed frame rate if the mode is fixed frame rate.doublegetHdiff()Provides the time difference in hoursgetTime()Gets the current timedoubleGets the current warp factorbooleanReturns whether the frame rate is set to fixed or notbooleanisTimeOn()Is the time on?voidvoidsetTimeWarp(double tw)voidupdate(double dt)Update function
-
Field Details
-
time
The current time of the clock -
fps
public float fpsThe fixed frame rate when not in real time. Set negative to use real time
-
-
Constructor Details
-
GlobalClock
Creates a new GlobalClock- Parameters:
timeWrap- The time wrap multiplierinstant- The instant with which to initialise the clock
-
-
Method Details
-
update
public void update(double dt)Update function- Specified by:
updatein interfaceITimeFrameProvider- Parameters:
dt- Delta time in seconds
-
getTime
Description copied from interface:ITimeFrameProviderGets the current time- Specified by:
getTimein interfaceITimeFrameProvider- Returns:
- The time as an instant
-
notify
-
setTimeWarp
public void setTimeWarp(double tw) -
getHdiff
public double getHdiff()Provides the time difference in hours- Specified by:
getHdiffin interfaceITimeFrameProvider- Returns:
- The simulation time difference in hours.
-
getDt
public double getDt()Description copied from interface:ITimeFrameProviderThe frame time difference in seconds.- Specified by:
getDtin interfaceITimeFrameProvider- Returns:
- The frame time difference in seconds.
-
getWarpFactor
public double getWarpFactor()Description copied from interface:ITimeFrameProviderGets the current warp factor- Specified by:
getWarpFactorin interfaceITimeFrameProvider- Returns:
- The warp factor
-
isFixedRateMode
public boolean isFixedRateMode()Description copied from interface:ITimeFrameProviderReturns whether the frame rate is set to fixed or not- Specified by:
isFixedRateModein interfaceITimeFrameProvider- Returns:
- Whether fix rate mode is on
-
getFixedRate
public float getFixedRate()Description copied from interface:ITimeFrameProviderReturns the fixed frame rate if the mode is fixed frame rate. Returns -1 otherwise- Specified by:
getFixedRatein interfaceITimeFrameProvider- Returns:
- The fixed rate
-
isTimeOn
public boolean isTimeOn()Description copied from interface:ITimeFrameProviderIs the time on?- Specified by:
isTimeOnin interfaceITimeFrameProvider- Returns:
- True if time is on
-