private void save() { try { ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("save.dat")); out.writeObject(snake); out.writeObject(apple); out.writeObject(snakeMoveDelay); out.writeObject(delay); out.writeObject(appleCount); out.writeObject(stepsCount); out.writeObject(mlSeconds); } catch (IOException e) { e.printStackTrace(); } }
private void load() { try { ObjectInputStream in = new ObjectInputStream(new FileInputStream("save.dat")); game.setScene( new MainScence( this.game, this.panel, (Snake) in.readObject(), (Apple) in.readObject(), (Delay) in.readObject(), (int) in.readObject(), (int) in.readObject(), (int) in.readObject(), (int) in.readObject())); } catch (IOException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } }