private void gameLoop() throws GameException 
	{
		long startTime;
		long elapsedTime;
		long averageTime = 0;
		long frameTime;

		while(gameRunning)			// This double loop is made to be able to restart the game after it stopped.
		{			
			while(gameRunning)
			{			
				startTime		=	System.nanoTime();
				
				repaint();
				myWorld.act();
				actorLoop();
				
				elapsedTime		=	System.nanoTime()-startTime;
				frameTime		=	timeMeasurement/maximumFPS;
			
				if(calcFPS)
				{
					averageTime = (9*averageTime+elapsedTime)/10;
					currentFPS = (int)(1.0/(averageTime/(double)(timeMeasurement)));
				}
			
				if(elapsedTime < frameTime)					// Maximum Frames erzeugen
				{	
					try {
						Thread.sleep((frameTime-elapsedTime)/timeMeasurementToMillis);
					} catch (InterruptedException e) 
					{
						throw new GameException(GameException.ERROR_DURING_WAITTIME);
					}				
				}
			}
			myWorld.gameStopped();
		}
	}