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(); }
/** * A method that sets up listeners to handle game input during game execution. Uses currently * loaded key values. */ @Override public void HandleGameInput() { window.redirectFocus(); window .getMainPanel() .addKeyListener( new KeyListener() { @Override public void keyTyped(KeyEvent arg0) {} @Override public void keyReleased(KeyEvent arg0) {} @Override public void keyPressed(KeyEvent arg0) { if (arg0.getKeyCode() == move_up_key) { theTab.movePlayer(0, -1); window.updateDrawbleContent(); } else if (arg0.getKeyCode() == move_down_key) { theTab.movePlayer(0, 1); window.updateDrawbleContent(); } else if (arg0.getKeyCode() == move_left_key) { theTab.movePlayer(-1, 0); window.updateDrawbleContent(); } else if (arg0.getKeyCode() == move_right_key) { theTab.movePlayer(1, 0); window.updateDrawbleContent(); } else if (arg0.getKeyCode() == send_eagle_key) { theTab.getEagle().StartEagle(theTab.getHero(), theTab.getSword()); window.updateDrawbleContent(); } } }); }
private void setupGameWindow() { window = new GameWindowViewController(this); window.makeVisible(); }
protected void init_JDialog() { Settings_Dialog d1 = new Settings_Dialog(window.getFrame(), this); d1.setVisible(true); }
/** * Switches the maze for a new one and updates the game content. * * @param newTab */ public void switch_Maze(Tabuleiro newTab) { theTab = newTab; window.updateDrawbleContent(); }