vooga.gameEngine.controller
Class TimingController

java.lang.Object
  extended by vooga.gameEngine.game.GameRelatedObject
      extended by vooga.gameEngine.controller.GameRelatedController
          extended by vooga.gameEngine.controller.TimingController
All Implemented Interfaces:
java.io.Serializable

public class TimingController
extends GameRelatedController

Class TimingController keeps track of the current time elapsed in a game or level.

Author:
Justin C. Klaassen, Scott Brothers
See Also:
Serialized Form

Constructor Summary
TimingController()
           
 
Method Summary
 void addTime(long dt)
          Adds the change in time, dt to the time.
 long getGameTime()
          Gives the current game time.
 long getTimeSinceLastFrame()
          Gives the time between frames.
 long getTotalGameTime()
          Gives the total game time since the game was started.
 long getTotalLevelTime()
          Gives the time since level start.
 void pauseTime()
          Marks the time in which a pause occurred.
 void resumeTime()
          Determines the length of the pause, and adds that amount to the total paused time for the overall game and the specific level.
 void startLevel()
          Starts a new level timer by setting the level start time to the current time.
 void startTime()
          Starts the timing with a start time of 0.
 void startTime(long startTime)
          Starts the timing with a given startTime.
 void TimeController()
          Creates a new time object with all values set to 0.
 void updateTime()
          Updates the time to the current time by adding the time elapsed since the last update was called.
 void updateTime(long time)
          Updates the time to the given time.
 
Methods inherited from class vooga.gameEngine.game.GameRelatedObject
addEventListener, clearListeners, equals, fire, fire, fire, getEventListeners, getID, getListenerCount, removeEventListener
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimingController

public TimingController()
Method Detail

TimeController

public void TimeController()
Creates a new time object with all values set to 0.


startTime

public void startTime()
Starts the timing with a start time of 0.


startTime

public void startTime(long startTime)
Starts the timing with a given startTime.

Parameters:
startTime - in milliseconds

updateTime

public void updateTime()
Updates the time to the current time by adding the time elapsed since the last update was called.


updateTime

public void updateTime(long time)
Updates the time to the given time.

Parameters:
time - to be changed to

addTime

public void addTime(long dt)
Adds the change in time, dt to the time.

Parameters:
dt - milliseconds to add

startLevel

public void startLevel()
Starts a new level timer by setting the level start time to the current time.


getTimeSinceLastFrame

public long getTimeSinceLastFrame()
Gives the time between frames.

Returns:
milliseconds since last updateTime() was called

getTotalLevelTime

public long getTotalLevelTime()
Gives the time since level start.

Returns:
milliseconds since startLevel() was called

getGameTime

public long getGameTime()
Gives the current game time.

Returns:
milliseconds representing current game time

getTotalGameTime

public long getTotalGameTime()
Gives the total game time since the game was started.

Returns:
milliseconds since the specified time at construction

pauseTime

public void pauseTime()
Marks the time in which a pause occurred.


resumeTime

public void resumeTime()
Determines the length of the pause, and adds that amount to the total paused time for the overall game and the specific level.