@Override
	public void run() {
		long fpsTimer = System.currentTimeMillis();
		int frames = 0;
		double nsPerTick = 1000000000.0 / _settings.getDouble("FPS", 60.0);
		long runNs;
		long lastNs;
		long nsToSleep = 0;
		double delta = 0;

		while (_running) {
			lastNs = System.nanoTime();
			runStep(delta);
			frames++;
			runNs = System.nanoTime();
			nsToSleep = (long) ((nsPerTick - (runNs - lastNs)));
			if (nsToSleep >= 0) {
				try {
					Thread.sleep(nsToSleep / 1000000,
							(int) (nsToSleep % 1000000));
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
			delta = (double) (System.nanoTime() - lastNs) / 1000000000;
			
			if (System.currentTimeMillis() - fpsTimer >= 1000) {
				_currentFps = frames;
				frames = 0;
				fpsTimer = System.currentTimeMillis();
			}
		}	
	}