Created Classes: 0
Affected Classes: 1
Summary of Changes: Interpolation value of update(float) is always -1. This would mean that the user would have to create a new variable: float interpolation = 1/super.getFramesPerSecond(); This would be avoided by using the interpolation in the update method:
/**
* Render and update logic at a specified fixed rate.
*/
public final void start() {
LoggingSystem.getLogger().log(Level.INFO, "Application started.");
try {
getAttributes();
timer = Timer.getTimer(properties.getRenderer());
setFrameRate(60); //default to 60 fps
initSystem();
assertDisplayCreated();
initGame();
//main loop
while (!finished && !display.isClosing()) {
startFrame();
//update game state, do use interpolation parameter
update((float)1/preferredTicksPerFrame);
//render, do not use interpolation parameter
render(-1.0f);
//swap buffers
display.getRenderer().displayBackBuffer();
endFrame();
}
} catch (Throwable t) {
t.printStackTrace();
} finally {
cleanup();
}
LoggingSystem.getLogger().log(Level.INFO, "Application ending.");
display.reset();
quit();
}
A similar method could be done for FixedLogicrateGame as well whereby the change is:
/**
* Ticks logic at a fixed rate while rendering as fast as hardware permits.
*/
public final void start() {
LoggingSystem.getLogger().log(Level.INFO, "Application started.");
try {
getAttributes();
timer = Timer.getTimer(properties.getRenderer());
setLogicTicksPerSecond(60); //default to 60 tps
initSystem();
assertDisplayCreated();
initGame();
//main loop
while (!finished && !display.isClosing()) {
time1 = timer.getTime();
loops = 0;
while ((time1 - time0) > tickTime && loops < MAX_LOOPS) {
//update game state, do use interpolation parameter
update((float)1/logicTPS);
time0 += tickTime;
loops++;
}
//If the game logic takes far too long, discard the pending
// time
if ((time1 - time0) > tickTime) time0 = time1 - tickTime;
float percentWithinTick = Math.min(1.0f,
(float) (time1 - time0) / tickTime);
//render scene with interpolation value
render(percentWithinTick);
//swap buffers
display.getRenderer().displayBackBuffer();
}
} catch (Throwable t) {
t.printStackTrace();
} finally {
cleanup();
}
LoggingSystem.getLogger().log(Level.INFO, "Application ending.");
display.reset();
quit();
}