Class GameClock
java.lang.Object
nz.ac.vuw.ecs.swen225.gp6.app.utilities.GameClock
This class is used to represent the timer for the game, it is also used to clock the time, and
define what happens with each ping during a game loop.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the time elapsed since the start of the game in Minutes and Seconds.longGets the time left for the current level.longGets the time elapsed since the start of the game.voidreset()Resets the timer to the initial state.voidResets the time left for the current level.voidsetObserver(Runnable ob) Sets the observer to fire during a replay session.voidsetReplaySpeed(float speed) Sets the delay between pings for the replay timer.voidsetTimePlayed(long timePlayed) Sets the time played in the previous session.voidstart()Starts the timer.voidstop()Stops the timer.voidSets the timer used for the game loop.voidSets the timer used for the replay loop.
-
Constructor Details
-
GameClock
Constructor for the GameTimer class.- Parameters:
app- The game object that the timer will be used on.
-
-
Method Details
-
start
public void start()Starts the timer. -
stop
public void stop()Stops the timer. -
reset
public void reset()Resets the timer to the initial state. -
setObserver
Sets the observer to fire during a replay session.- Parameters:
ob- the observer to be set
-
setReplaySpeed
public void setReplaySpeed(float speed) Sets the delay between pings for the replay timer.- Parameters:
speed- the delay in milliseconds
-
resetTime
public void resetTime()Resets the time left for the current level. -
useGameTimer
public void useGameTimer()Sets the timer used for the game loop. -
useReplayTimer
public void useReplayTimer()Sets the timer used for the replay loop. -
getTimePlayed
public long getTimePlayed()Gets the time elapsed since the start of the game.- Returns:
- the time elapsed since the start of the game
-
setTimePlayed
public void setTimePlayed(long timePlayed) Sets the time played in the previous session.- Parameters:
timePlayed- the time played in the previous session
-
getTimeLeft
public long getTimeLeft()Gets the time left for the current level.- Returns:
- the time left for the current level in nanoseconds
-
getTimeInMinutes
Gets the time elapsed since the start of the game in Minutes and Seconds.- Returns:
- the time elapsed since the start of the game
-