}
private void gameLoop(final GameScreen gameScreen) {
final int frameLength = (int) (1000.0 / stendhal.FPS_LIMIT);
int fps = 0;
final GameObjects gameObjects = client.getGameObjects();
final StaticGameLayers gameLayers = client.getStaticGameLayers();
try {
SoundGroup group = initSoundSystem();
group.play("harp-1", 0, null, null, false, true);
} catch (RuntimeException e) {
logger.error(e, e);
}
// keep looping until the game ends
long refreshTime = System.currentTimeMillis();
long lastFpsTime = refreshTime;
long lastMessageHandle = refreshTime;
gameRunning = true;
boolean canExit = false;
while (!canExit) {
try {
fps++;
// figure out what time it is right after the screen flip then
// later we can figure out how long we have been doing redrawing
// / networking, then we know how long we need to sleep to make
// the next flip happen at the right time
screenController.nextFrame();
final long now = System.currentTimeMillis();
final int delta = (int) (now - refreshTime);
refreshTime = now;
logger.debug("Move objects");
gameObjects.update(delta);
if (gameLayers.isAreaChanged()) {
// Same thread as the ClientFramework loop, so these should
// be save
/*