org.deken.game
Class GameTimer

java.lang.Object
  extended by org.deken.game.GameTimer
Direct Known Subclasses:
DualProcGameTimer, ManualGameTimer

public abstract class GameTimer
extends java.lang.Object

Title: GameTimer

Description: Abstract GameTimer. The abstract methods are implemented inside the GameCanvas.

Copyright: Copyright (c) Dec 12, 2010

Version:
1.0
Author:
Gary Deken

Field Summary
protected  boolean listeners
           
static int MAX_FRAME_SKIPS
           
static int NO_DELAYS_PER_YIELD
           
static long period
          100 Frames per second (FPS) 1000sec/100frames = 10 ms.
protected  boolean running
           
protected  java.util.List<TimeListener> timeListeners
           
protected  long totalTime
           
 
Constructor Summary
GameTimer()
           
 
Method Summary
 void addTimeListeners(TimeListener timeListener)
          Adds a TimeListener to this GameTimer for receiving the number of seconds.
 boolean isRunning()
          Returns if this GameTimer is running or not.
abstract  void paint()
           
abstract  void render()
           
 void resetGameTime()
           
 void run()
           
 void setRefreshRate(int refreshRate)
          Make the Frames per second equivalent to the refresh rate.
 void setRunning(boolean running)
          Set if the game is running or not.
protected  long tick()
           
abstract  void update(long deltaTime)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

period

public static long period
100 Frames per second (FPS) 1000sec/100frames = 10 ms. 40 is average 62 FPS 30 is average 70 FPS 20 is average 76 FPS 15 is average 96 FPS 10 is average 110 FPS


NO_DELAYS_PER_YIELD

public static final int NO_DELAYS_PER_YIELD
See Also:
Constant Field Values

MAX_FRAME_SKIPS

public static final int MAX_FRAME_SKIPS
See Also:
Constant Field Values

timeListeners

protected java.util.List<TimeListener> timeListeners

listeners

protected boolean listeners

running

protected volatile boolean running

totalTime

protected long totalTime
Constructor Detail

GameTimer

public GameTimer()
Method Detail

update

public abstract void update(long deltaTime)

render

public abstract void render()

paint

public abstract void paint()

run

public void run()

addTimeListeners

public void addTimeListeners(TimeListener timeListener)
Adds a TimeListener to this GameTimer for receiving the number of seconds.

Parameters:
timeListener -

setRefreshRate

public void setRefreshRate(int refreshRate)
Make the Frames per second equivalent to the refresh rate.

Parameters:
refreshRate -

setRunning

public void setRunning(boolean running)
Set if the game is running or not.

Parameters:
running -

resetGameTime

public void resetGameTime()

isRunning

public boolean isRunning()
Returns if this GameTimer is running or not.

Returns:
running

tick

protected long tick()
Returns:
time in milliseconds