com.jme.app
Class FixedLogicrateGame

java.lang.Object
  extended by com.jme.app.AbstractGame
      extended by com.jme.app.FixedLogicrateGame

public abstract class FixedLogicrateGame
extends AbstractGame

FixedLogicrateGame implements a main-loop designed to acheive frame rate independence. The goal is to keep a consistent gameplay speed regardless of the framerate acheived by the visuals. The game renders as fast as the hardware permits, while running the game logic at a fixed rate. The concept behind this is forcing every game logic tick to represent a fixed amount of real-time. For example, if the logic is updated at a rate of 15 times per second, and we have a person moving at 30 pixels per second, each update the person should move 2 pixels.
To compensate for the non-constant frame rate, we smooth the visuals using interpolation. So, if the scene is rendered twice without the game logic being updated, we do not render the same thing twice.
Using a fixed-timestep model has a number of benefits. Game logic is simplified as there is no longer any need to add "*deltaTime" to acheive frame rate independence. There is also a gain in efficiency: the logic can be run at a lower frequency than the rendering, meaning that the logic may be updated only once every second game - a net save in time. In addition, because the exact same sequence of game logic code is executed every time, the game becomes deterministic (that is to say, it will run the exact same way every time).
Further extension of this class could be used to integrate both a fixed logic rate and a fixed frame rate.

Version:
$Id: FixedLogicrateGame.java,v 1.6 2004/04/26 18:56:01 mojomonkey Exp $
Author:
Eric Woroshow

Nested Class Summary
 
Nested classes/interfaces inherited from class com.jme.app.AbstractGame
AbstractGame.ConfigShowMode
 
Constructor Summary
FixedLogicrateGame()
           
 
Method Summary
 void setLogicTicksPerSecond(int tps)
          setLogicTicksPerSecond sets the number of logic times per second the game should update the logic.
 void start()
          Ticks logic at a fixed rate while rendering as fast as hardware permits.
 
Methods inherited from class com.jme.app.AbstractGame
finish, getVersion, setConfigShowMode, setConfigShowMode
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FixedLogicrateGame

public FixedLogicrateGame()
Method Detail

setLogicTicksPerSecond

public void setLogicTicksPerSecond(int tps)
setLogicTicksPerSecond sets the number of logic times per second the game should update the logic. This should not be called prior to the application being start() -ed.

Parameters:
tps - the desired logic rate in ticks per second

start

public final void start()
Ticks logic at a fixed rate while rendering as fast as hardware permits.

Specified by:
start in class AbstractGame