@Override
	public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException {
		gui.updateStats();
		rm.update(delta);
		map.checkZone(p);
		gui.setZone(map.getZone());
		p.updateTimers(delta);
		Input in = gc.getInput();
		Vector2f v = new Vector2f (in.getMouseX(), in.getMouseY());
		if (v != lastMouse){
			gui.checkMouseHover(v);
		}
		if (in.isMousePressed(Input.MOUSE_LEFT_BUTTON)){
			gui.checkMouseClick(v,0);
			cam.checkMouseClick(v,0);
		}
		if (in.isMousePressed(Input.MOUSE_RIGHT_BUTTON)){
			gui.checkMouseClick(v, 1);
		}
		if (in.isKeyPressed(Input.KEY_G)){
			gui.addItem();
		}
		if (in.isKeyPressed(Input.KEY_ESCAPE)){
			System.exit(0);
		}
		if (in.isKeyPressed(Input.KEY_F1)){
			if (showDebug){
				showDebug = false;
				gc.setShowFPS(false);
			}
			else{
				showDebug = true;
				gc.setShowFPS(true);
			}
		}
		if (in.isKeyPressed(Input.KEY_F2)){
			boolean val = p.isInvincible();
			p.setInvincible(!val);
		}
		if (in.isKeyPressed(Input.KEY_F3)){
			int k = map.getLootChance();
			if (k >= 90){
				map.setLootChance(0);
			}
			else{
				map.setLootChance(90);
			}
		}
		if (in.isKeyPressed(Input.KEY_SPACE)){
			ArrayList<Item> items = map.getItemList();
			for (int i = 0; i < items.size(); i++){
				Item item = items.get(i);
				if (p.intersects(item) || p.contains(item)){
					int val = gui.isBagFull();
					if (val >= 0){
						gui.addItem(item, val);
						item.setOnGround(false);
						items.remove(i);
						i -= 1;
					}
				}
			}
		}
		if (in.isKeyDown(Input.KEY_E) || in.isMouseButtonDown(4)){
			p.attack(cam.getMobsOnScreen());
		}
		/**
		 * Player movement.
		 */
		if (cam.isMoving()){
			p.update(delta);
		}
		if (in.isKeyDown(Input.KEY_W) && !cam.isMoving()){
			p.setFacing(Facing.NORTH);
			if (map.canMove(p) && !cam.checkMobCollision()){
				cam.moveCamera(Facing.NORTH);
				p.move(Facing.NORTH);
				p.setTileY(p.getTileY() - 1);
			}
		}
		if (in.isKeyDown(Input.KEY_S) && !cam.isMoving()){
			p.setFacing(Facing.SOUTH);
			if (map.canMove(p) && !cam.checkMobCollision()){
				cam.moveCamera(Facing.SOUTH);
				p.move(Facing.SOUTH);
				p.setTileY(p.getTileY() + 1);
			}
		}
		if (in.isKeyDown(Input.KEY_A) && !cam.isMoving()){
			p.setFacing(Facing.WEST);
			if (map.canMove(p) && !cam.checkMobCollision()){
				cam.moveCamera(Facing.WEST);
				p.move(Facing.WEST);
				p.setTileX(p.getTileX() - 1);
			}
		}
		if (in.isKeyDown(Input.KEY_D) && !cam.isMoving()){
			p.setFacing(Facing.EAST);
			if (map.canMove(p) && !cam.checkMobCollision()){
				cam.moveCamera(Facing.EAST);
				p.move(Facing.EAST);
				p.setTileX(p.getTileX() + 1);
			}
		}
		if (in.isKeyDown(Input.KEY_LSHIFT)){
			
		}
		else if (!in.isKeyDown(Input.KEY_LSHIFT)){
			
		}
		
		if (map.isHealing(p)){
			float dx = (float) (p.getInfo().getMaxHP() * .001);
			p.getInfo().changeHP(dx);
		}
		
		//debug
		mouseX = in.getMouseX();
		mouseY = in.getMouseY();
		
		//camera update (must come after movements)
		cam.update(delta);
	}