예제 #1
0
  public static void loadAllOpenLevels(Player player, RandomAccessFile loadfile)
      throws IOException {
    System.out.printf("Entering map loader at %d!\n", loadfile.getFilePointer());
    int mapsToLoad = loadfile.readInt();

    for (int x = 0; x < mapsToLoad; x++) {
      System.out.printf("Loading a map at %d!\n", loadfile.getFilePointer());
      int layer = loadfile.readInt();
      System.out.printf("Looks like it's map %d!\n", layer);
      loadMap(layer, player, loadfile);
    }
  }
예제 #2
0
 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);
     }
   }
 }
예제 #3
0
  public void saveAllOpenLevels(RandomAccessFile savefile) throws IOException {
    System.out.printf("Entering map saver at %d!\n", savefile.getFilePointer());
    int mapsToSave = loadedMaps.size();
    savefile.writeInt(mapsToSave);

    saveMap(1, savefile);
    saveMap(0, savefile);
    saveMap(-1, savefile);
    saveMap(-2, savefile);
    saveMap(-100, savefile);
  }
예제 #4
0
 public static void loadMap(int layer, Player player, RandomAccessFile loadfile)
     throws IOException {
   Level level =
       new Level(Art.load("/res/map/layer_" + layer + ".png"), null, player, layer, true);
   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", loadfile.getFilePointer());
       }
       Tile tileToSave = level.getTile(x, y);
       tileToSave.loadTile(loadfile);
     }
   }
   level.init();
   loadedMaps.put(layer, level);
 }