Hi,
I am encountering an awful graphical rendering for a Java-Game and it seems to come from an unreliable refresh rate. I use a classical game loop :
public void loop(long elapsedTime) {
Graphics2D g = (Graphics2D) frame.getBufferStrategy().getDrawGraphics();
stage.update(elapsedTime);
stage.draw(g);
g.dispose();
frame.getBufferStrategy().show();
}
Depending on the ‘stage.update(elapsedTime);’ and ‘stage.draw(g);’ steps, the duration of a loop can vary a lot, and from time to time, it can takes more than 100 ms. This way objects (sprites) on the graphical scene seems more to make discrete jumps from a position to another rather than to follow a continuous path. I think this rendering is non acceptable for a game.
Anyway, I have always seen such behviour of Java apps when they have animations so I am not really optimist. The only solution I see is to try to control the maximal duration of operations in a loop and to try to avoid the unpredictable ones (it don’t seem to be possible at 100%).
So my questions are : do you encounter the same problem ? do you agree with the diagnostic ? do you have a solution ?
Thanks everybody,
Guillaume