private static void movement()
	{
		int speed;
		if(sprintkey)speed = player.movespeed_sprint;
		else speed = player.movespeed;
		int
			uppenalty = 1,
			downpenalty = 1,
			leftpenalty = 1,
			rightpenalty = 1;
		double modify = 1;	
		
		if(player.rotate > -45 && player.rotate < 45)
		{
			//forward = up;
			uppenalty = 1;
			leftpenalty = 1;
			rightpenalty = 1;
			downpenalty = 0;
		}
		else if(player.rotate > 135 || player.rotate < -135)
		{
			//forward = down;
			uppenalty = 0;
			leftpenalty = 1;
			rightpenalty = 1;
			downpenalty = 1;
		}
		else if(player.rotate > -135 && player.rotate < -45)
		{
			//forward = left;
			uppenalty = 1;
			leftpenalty = 0;
			rightpenalty = 1;
			downpenalty = 1;
		}
		else if(player.rotate > 45 && player.rotate < 135)
		{
			//forward = right;
			uppenalty = 1;
			leftpenalty = 1;
			rightpenalty = 0;
			downpenalty = 1;
		}

		if(moveup&&moveleft&&player.y-((speed/modify)-uppenalty) > 0&& player.x -((speed/modify)-leftpenalty) >0 )
		{
			player.y -= (speed/modify)-uppenalty;
			player.x -= (speed/modify)-leftpenalty;
		}
		else if(moveup&&moveright&&player.y-((speed/modify)-uppenalty) > 0&& player.x -((speed/modify)-leftpenalty) <width-player.width)
		{
			player.y -= (speed/modify)-uppenalty;
			player.x += (speed/modify)-rightpenalty;					
		}
		else if(movedown&&moveleft&&player.y+((speed/modify)-uppenalty) < height-player.height&& player.x -((speed/modify)-leftpenalty) >0)
		{
			player.y += (speed/modify)-downpenalty;
			player.x -= (speed/modify)-leftpenalty;										
		}
		else if(movedown&&moveright&&player.y+((speed/modify)-uppenalty) < height-player.height&& player.x -((speed/modify)-leftpenalty) <width-player.width)
		{
			player.y += (speed/modify)-downpenalty;
			player.x += (speed/modify)-rightpenalty;										
		}
		else
		{
			if(moveup&&player.y-((speed/modify)-uppenalty) > 0)player.y -= speed-uppenalty;
			if(movedown&&player.y+((speed/modify)-uppenalty) < height-player.height)player.y += speed-downpenalty;
			if(moveleft&& player.x -((speed/modify)-leftpenalty) >0)player.x -= speed-leftpenalty;
			if(moveright&& player.x -((speed/modify)-leftpenalty) <width-player.width)player.x += speed-rightpenalty;					
		}		
	}