package ru.deadsoftware.cavecraft.game; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.files.FileHandle; import ru.deadsoftware.cavecraft.CaveGame; import ru.deadsoftware.cavecraft.Items; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.nio.ByteBuffer; public class GameSaver { private static final int VERSION = 0; private static int[][] fMap, bMap; private static int readIndex; private static int bytesInt(byte[] bytes) { ByteBuffer wrapped = ByteBuffer.wrap(bytes); int res = wrapped.getInt(readIndex); readIndex+=4; return res; } private static void writeInt(FileHandle file, int i, boolean append) { byte[] bytes = ByteBuffer.allocate(4).putInt(i).array(); file.writeBytes(bytes, append); } private static void saveMap(FileHandle file, int[][] map) { int rl,bl; int width = map.length; int height = map[0].length; writeInt(file, VERSION, false); writeInt(file, width, true); writeInt(file, height, true); for (int y=0; y