package ru.deadsoftware.cavecraft.game; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.files.FileHandle; import ru.deadsoftware.cavecraft.CaveGame; import java.io.*; import java.nio.ByteBuffer; public class GameSaver { private static final int VERSION = 0; 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