Class Base

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants

public class Base extends JFrame
Base is the base window that all actions occur on.
Author:
Molly
See Also:
  • Constructor Details

    • Base

      public Base()
      Begin program here. Run menu phase.
  • Method Details

    • runClosePhase

      public void runClosePhase()
      Remove all components in window, clears list and stops timer.
    • setLevel

      public static void setLevel(int lvl)
      Sets current level.
      Parameters:
      lvl - current level
    • setTime

      public static void setTime(int t)
      Sets current game time.
      Parameters:
      t - time in seconds
    • getLevel

      public static int getLevel()
      Returns current level.
      Returns:
      current level number
    • getTime

      public static int getTime()
      Returns current game time.
      Returns:
      game time in seconds
    • startGame

      public void startGame()
      When you click start button, check for last save file and run the level.
    • pause

      public void pause()
      Pauses game.
    • unPause

      public void unPause()
      Un-pauses game.
    • replayPhase

      public void replayPhase()
      Creates and runs re-player window.
    • loadGame

      public void loadGame()
      Load a game from file.
    • newGame

      public void newGame(int lvl)
      Loads new level, makes new recorder.
      Parameters:
      lvl - level number to load
    • saveGame

      public void saveGame()
      Save the current game.
    • resetFocus

      public void resetFocus()
      Resets focus to Base window (not pop-up).
    • saveExit

      public void saveExit()
      Saves the game and then exits.
    • playerDied

      public void playerDied()
      Saves recorder, pops up game over screen.
    • playerWon

      public void playerWon()
      Saves recorder, pops up game won screen.
    • nextLevel

      public void nextLevel(int lvl)
      Displays next level pop-up, stops game.
      Parameters:
      lvl - the next level
    • exitGame

      public void exitGame()
      Exit the game.
    • movePlayer

      public void movePlayer(Entity.Direction dir)
      When key is pressed, move player and tell recorder.
      Parameters:
      dir - direction player moves
    • getGameWindow

      public PhasePanel getGameWindow()
      Gets the game window.
      Returns:
      game window
    • undo

      public void undo(List<Action> actions)
      Undoes action.
      Parameters:
      actions - List of Recorder actionRecords.
    • apply

      public void apply(List<Action> actions)
      Apply action.
      Parameters:
      actions - List of Recorder actionRecords.
    • getAction

      public Entity.Action getAction(Action action)
      Transforms Recorder Action into Domain Action.
      Parameters:
      action - Recorder action.
      Returns:
      Domain Action.
    • loadLevel

      public void loadLevel()
      Create, run and draw new level.
    • changeKeyListener

      public void changeKeyListener(KeyListener keyListener)
      Removes current key listener, adds new one. Use to ensure there is only one key listener being used at any given time.
      Parameters:
      keyListener - new key-listener to use