@Override
	public void mouseClicked(MouseEvent arg0) {
		int x = arg0.getX()/(ImageResources.TILE_SIZE * zoom);
		int y = arg0.getY()/(ImageResources.TILE_SIZE * zoom);
		if(arg0.getButton() == MouseEvent.BUTTON1) {
			ImageResource r = resPanel.getSelectedResource();
			if(r != null) {
				Tile t;
				if(level.getTile(x, y) == null) {
					t = new Tile(x, y);
					level.setTile(x, y, t);
				} else {
					t = level.getTile(x, y);
				}
				t.setResource(r);
				this.repaint();
			} else {
				select(x, y);
			}
			
		}else if(arg0.getButton() == MouseEvent.BUTTON3) {
			ImageResource r = resPanel.getSelectedResource();
			if(r != null) {
				Tile t;
				if(level.getTile(x, y) == null) {
					t = new Tile(x, y);
					level.setTile(x, y, t);
				} else {
					t = level.getTile(x, y);
				}
				t.setBackground(r);
				this.repaint();
			} else {
				select(x, y);
			}
		}else if(arg0.getButton() == MouseEvent.BUTTON2) {
			select(x, y);
		}
		if(selectedX == x && selectedY == y) {
			select(x, y);
		}
		
	}