Class GameClock

java.lang.Object
nz.ac.vuw.ecs.swen225.gp6.app.utilities.GameClock

public class GameClock extends Object
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 Details

    • GameClock

      public GameClock(App app)
      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

      public void setObserver(Runnable ob)
      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

      public String 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