package ru.deadsoftware.cavecraft.game; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.files.FileHandle; import ru.deadsoftware.cavecraft.CaveGame; import java.io.BufferedOutputStream; import java.io.IOException; 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 bytesToInt(byte[] bytes) { ByteBuffer wrapped = ByteBuffer.wrap(bytes); int res = wrapped.getInt(readIndex); readIndex+=4; return res; } private static byte[] intToBytes(int i) { return ByteBuffer.allocate(4).putInt(i).array(); } private static void saveMap(FileHandle file, int[][] map) throws IOException{ int rl,bl; int width = map.length; int height = map[0].length; BufferedOutputStream out = new BufferedOutputStream(file.write(false)); out.write(intToBytes(VERSION)); out.write(intToBytes(width)); out.write(intToBytes(height)); for (int y=0; y