Why does my game loop speed vary on different platforms with the same hardware?
Posted
by
Sri Harsha Chilakapati
on Game Development
See other posts from Game Development
or by Sri Harsha Chilakapati
Published on 2012-09-30T00:35:43Z
Indexed on
2012/09/30
3:50 UTC
Read the original article
Hit count: 358
I've got a serious issue with my game loop. This loop varies in time with the platform and with the same hardware. This is a list of FPS
achieved:
- Windows ======= 140 to 150
- Linux ======= 120 to 125
- Windows(WINE) ======= 125 to 135
And since my game loop is fixed timestep, the speed of the game is not stable. Here's my game loop.
public final void run() {
// Initialize the resources
Map.initMap();
initResources();
// Start the timer
GTimer.startTimer();
GTimer.refresh();
long elapsedTime = 0;
// The game loop
while (running) {
// Update the game
update(elapsedTime);
if (state == GameState.GAME_PLAYING) {
Map.updateObjects(elapsedTime);
}
// Show or hide the cursor
if (Global.HIDE_CURSOR) {
setCursor(GInput.INVISIBLE_CURSOR);
} else {
setCursor(Cursor.getDefaultCursor());
}
// Repaint the game and sync
repaint();
elapsedTime = GTimer.sync();
Toolkit.getDefaultToolkit().sync();
}
}
How could I improve it?
© Game Development or respective owner