Package dev.prozilla.pine.core.state
Class Timer
java.lang.Object
dev.prozilla.pine.core.state.Timer
- All Implemented Interfaces:
Initializable
Manages time tracking, including FPS (frames per second) and UPS (updates per second) calculations.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classprotected static classstatic class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidUpdates FPS and UPS if a whole second has passed.doublefloatintgetFPS()floatfloatdoublegetTime()intgetUPS()voidvoidvoidinit()Initializes this object to prepare its usage.voidUpdates the timer's delta values and elapsed time values.startInterval(Callback callback, float delay) startInterval(Callback callback, float delay, boolean applyTimeScale) startRandomInterval(Callback callback, float minDelay, float maxDelay) startRandomInterval(Callback callback, float minDelay, float maxDelay, boolean applyTimeScale) startTimeout(Callback callback, float delay) startTimeout(Callback callback, float delay, boolean applyTimeScale) voidstopInterval(Timer.Interval interval) voidstopTimeout(Timer.Timeout timeout) void
-
Field Details
-
timeScale
public float timeScaleThe scale at which time passes.
-
-
Constructor Details
-
Timer
public Timer()
-
-
Method Details
-
init
public void init()Description copied from interface:InitializableInitializes this object to prepare its usage.- Specified by:
initin interfaceInitializable
-
nextFrame
public void nextFrame()Updates the timer's delta values and elapsed time values. -
updateTimedActions
public void updateTimedActions() -
incrementFPS
public void incrementFPS() -
incrementUPS
public void incrementUPS() -
checkCounters
public void checkCounters()Updates FPS and UPS if a whole second has passed. -
getFPS
public int getFPS()- Returns:
- Frames per second
-
getUPS
public int getUPS()- Returns:
- Updates per second
-
getCurrentTime
public double getCurrentTime()- Returns:
- Time elapsed since GLFW was initialized in seconds.
-
getTime
public double getTime()- Returns:
- Time elapsed at the start of the current frame since GLFW was initialized, in seconds.
-
getScaledElapsedTime
public float getScaledElapsedTime() -
getDeltaTime
public float getDeltaTime() -
getScaledDeltaTime
public float getScaledDeltaTime() -
startInterval
-
startInterval
-
startTimeout
-
startTimeout
-
startRandomInterval
-
startRandomInterval
public Timer.RandomInterval startRandomInterval(Callback callback, float minDelay, float maxDelay, boolean applyTimeScale) -
stopInterval
-
stopTimeout
-