public static void clearLevels() { for (int x = -2; x <= 1; x++) { if (loadedMaps.get(x) != null) { loadedMaps.put(x, null); } } }
public static Level get(int layer, Player player) { Level level = loadedMaps.get(layer); if (level == null) { level = new Level( Art.load("/res/map/layer_" + layer + ".png"), Art.load("/res/map/items_" + layer + ".png"), player, layer); loadedMaps.put(layer, level); } return level; }
public void saveMap(int layer, RandomAccessFile savefile) throws IOException { System.out.printf("Saving map %d at %d!\n", layer, savefile.getFilePointer()); Level level = loadedMaps.get(layer); if (level == null) { return; } savefile.writeInt(layer); for (int x = 0; x < level.w; x++) { for (int y = 0; y < level.h; y++) { if (x == 0 && y == 0) { System.out.printf("Entering first tile at %d!\n", savefile.getFilePointer()); } Tile tileToSave = level.getTile(x, y); tileToSave.saveTile(savefile); } } }