public float getHeight(final float xPart, final float yPart) { final float xPartRev = 1f - xPart; final float yPartRev = 1f - yPart; final float h00 = height; final float h10 = x != map.getWidth() ? map.getTile(this, 1, 0).height : 0; final float h01 = y != map.getHeight() ? map.getTile(this, 0, 1).height : 0; final float h11 = (x != map.getWidth() && y != map.getHeight()) ? map.getTile(this, 1, 1).height : 0; final float x0 = (h00 * xPartRev + h10 * xPart); final float x1 = (h01 * xPartRev + h11 * xPart); return (x0 * yPartRev + x1 * yPart); }
public MapBuilder(String name, File toLoad, File toSave, String tileDir) { super(name); currTileImg = null; currTileLoc = ""; try { System.out.println(tileDir); currTileImg = new ImageIcon(getTile(tileDir, 0, 0, DISPLAY_SCALE)); currTileLoc = "0_0"; } catch (IOException e) { System.out.println("Generating current tile failed."); System.out.println(e); System.exit(0); } currTileDisplay = new JLabel(new ImageIcon(scaleImage(currTileImg.getImage(), 2))); this.input = toLoad; output = toSave; this.tileDir = tileDir; if (toLoad != null) { try { backEnd = loadMap(toLoad); } catch (FileNotFoundException e) { System.err.println("Could not find input file."); System.exit(0); } } else { backEnd = emptyMap(DEFAULT_WIDTH, DEFAULT_HEIGHT); } mapWidth = backEnd.getWidth(); mapHeight = backEnd.getHeight(); }