This is my current game loop. Though I wanted to make it fixed-step, the game is running a lot faster on windows.
public void gameLoop(){
// Game loop initialization
long elapsedTime = 0;
long lastUpdateTime = getCurrentTime();
long currentTime = lastUpdateTime;
// Time taken by a frame
long frameTime = 0;
// The maximum time of a frame
long expectedET = 1000/Global.STEPS_FOR_SECOND;
while (running){
// Measure the time
currentTime = getCurrentTime();
elapsedTime = currentTime - lastUpdateTime;
// Don't run zero or negative length frames
if (elapsedTime <= 0)
continue;
// Update the game
while (elapsedTime > 0) {
frameTime = elapsedTime;
if (frameTime > expectedET)
frameTime = expectedET;
updateGame(frameTime);
elapsedTime -= frameTime;
}
displayGame();
lastUpdateTime = currentTime;
}
}
Any Ideas to make it uniform on every platform?
Solved now. I’m mistaken for variable time step