public void loadGame(String name) { try { name = name.concat(".save"); FileInputStream fileIn = new FileInputStream(name); ObjectInputStream in = new ObjectInputStream(fileIn); theTab = null; theTab = (Tabuleiro) in.readObject(); in.close(); fileIn.close(); } catch (IOException i) { JOptionPane.showMessageDialog( window.getFrame(), "File not Found !", "IOException not found", JOptionPane.ERROR_MESSAGE); i.printStackTrace(); return; } catch (ClassNotFoundException c) { JOptionPane.showMessageDialog( window.getFrame(), "File is not valid !", "ClassNotFoundException", JOptionPane.ERROR_MESSAGE); c.printStackTrace(); return; } theTab.printLayout(); window.updateDrawbleContent(); }
/** Creates a game window and does the necessary operations to generate a proper maze */ public void makeGame() { LabGenerator.prepareLab(labSize); char[][] lab = LabGenerator.getLab(); System.out.println("starting game with mode=" + mode); theTab = new Tabuleiro(0, 0, 0, 0, lab, mode, nrOfDragons); theTab.printLayout(); window.updateDrawbleContent(); }
/** * Switches the maze for a new one and updates the game content. * * @param newTab */ public void switch_Maze(Tabuleiro newTab) { theTab = newTab; window.updateDrawbleContent(); }