Package com.csse3200.game.services
Class GameTime
java.lang.Object
com.csse3200.game.services.GameTime
Controls the game time
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfloat
Get the time since the last frame in seconds, scaled by time scalefloat
Get the raw time since the last frame in secondslong
getTime()
Get the time since the game started in millisecondslong
getTimeSince
(long lastTime) Get the time since the last time in millisecondsvoid
setTimeScale
(float timeScale) Set the speed of time passing.
-
Constructor Details
-
GameTime
public GameTime()Constructor for the GameTime class.
-
-
Method Details
-
setTimeScale
public void setTimeScale(float timeScale) Set the speed of time passing. This affects getDeltaTime()- Parameters:
timeScale
- Time scale, where normal speed is 1.0, no time passing is 0.0
-
getDeltaTime
public float getDeltaTime()Get the time since the last frame in seconds, scaled by time scale- Returns:
- time passed since the last frame in seconds, scaled by time scale.
-
getRawDeltaTime
public float getRawDeltaTime()Get the raw time since the last frame in seconds- Returns:
- time passed since the last frame in seconds, not affected by time scale.
-
getTime
public long getTime()Get the time since the game started in milliseconds- Returns:
- time passed since the game started in milliseconds
-
getTimeSince
public long getTimeSince(long lastTime) Get the time since the last time in milliseconds- Parameters:
lastTime
- the time to get the time since- Returns:
- the time since the last time
-