@Override
	public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException
	{	
		// scale + dimension
		int alphabetWidth = 650;
		int pad = 50;
		float scale = (float) (WIDTH - 2 * pad) / alphabetWidth;
		
        //getMouse Input
		mouseRect.x = Mouse.getX();
		mouseRect.y = (int)(HEIGHT - Mouse.getY());
		
		// keyboard input
		input = container.getInput();

		// catch keys pressed
		if(input.isKeyPressed(Input.KEY_ENTER))
		
		{
			SoundEffect.VALIDATION.play();
			// get the last scores list
			scoresList = retrieveScores();
			
			// change the name of the current player in the scores list
			int indexCurrentScore = scoresList.getLastScoreIndex();
			System.out.println(" score index: " + indexCurrentScore);
			scoresList.setScoreName(indexCurrentScore, name);
			System.out.println(" current score (with new name):\n"
					+ scoresList.getSingleScore(indexCurrentScore));
			scoresList.setCurrentPlayerName(name);
			System.out.println("current player: " 
			        + scoresList.getCurrentPlayerName());
			
			// save the list
			saveScores(scoresList);
			
			// change state
			game.enterState(2);
		}
		
		if(input.isKeyPressed(Input.KEY_ESCAPE))
		{	
			container.exit();
		}
		
		if(input.isMousePressed(0)){
			SoundEffect.SELECT.play();
			char c = 'A';
			int x = input.getMouseX();
			int y = input.getMouseY();
			
			int letterWidth = Math.round(50 * scale);
			int xInGrid = x - pad;
			int yInGrid = y - pad;
			int position = xInGrid / letterWidth 
					       + 13 * (yInGrid / letterWidth);
			
			// update the name (no more then 10 characters)
			if (position < ALPHABET.length() && name.length() < 10) {
				c = ALPHABET.charAt(position);
				name += c;
			}
			
			System.out.println(x + " " + y + ": " + c + "/pos=" + position);
		}
		
		// delete the last character of name string
		if (input.isKeyPressed(Input.KEY_BACK)) {
			SoundEffect.BAD.play();
			if (name.length() > 0)
				name = name.substring(0, name.length() - 1);
		}
		
	}