MapPanel(Map map){
	requestFocus();
	setBackground(Color.BLACK);
	this.map=map;
	this.map.setPanel(this);
	setPreferredSize(new Dimension(img[0].getWidth(),img[0].getHeight()));
	
	g2d[0] = img[0].createGraphics();
	g2d[1] = img[1].createGraphics();
    
	addKeyListener(new KeyAdapter() {
		@Override
		public void keyPressed(KeyEvent e) {
		if(e.getKeyCode() == KeyEvent.VK_LEFT) {mappos.x+=10;}
		if(e.getKeyCode() == KeyEvent.VK_RIGHT) {mappos.x-=10;}
		if(e.getKeyCode() == KeyEvent.VK_UP) {mappos.y+=10;}
		if(e.getKeyCode() == KeyEvent.VK_DOWN) {mappos.y-=10;}
		
		if (mappos.x>0)mappos.x=0;
		if (mappos.y>0)mappos.y=0;
		if (mappos.x<screen.getSize().width-img[0].getWidth())  mappos.x=screen.getSize().width-img[0].getWidth();
		if (mappos.y<screen.getSize().height-img[0].getHeight()) mappos.y=screen.getSize().height-img[0].getHeight();
		
		if(img[0].getWidth()<800){
			mappos.x = (screen.getSize().width-img[0].getWidth())/2;
			mappos.y = (screen.getSize().height-img[0].getHeight())/2;
		}
		
		
		repaint();
		}
	});
	
	
	addMouseListener(m);
	addMouseMotionListener(m);
	
	}