Package tetris.gui

Class GUI

java.lang.Object
tetris.gui.GUI

public class GUI extends Object
The class GUI implements the graphical user interface of the Tetris game.
Version:
2.1
Author:
Stephan Fischli
  • Constructor Details

    • GUI

      public GUI(int width, int height)
      Constructs a graphical user interface.
      Parameters:
      width - the width of the field
      height - the height of the field
    • GUI

      public GUI(int width, int height, int scaleFactor)
      Constructs a graphical user interface.
      Parameters:
      width - the width of the field
      height - the height of the field
      scaleFactor - the scale factor
  • Method Details

    • setActionHandler

      public void setActionHandler(ActionHandler handler)
      Registers the handler of the figure action events.
      Parameters:
      handler - the action handler
    • setStatusHandler

      public void setStatusHandler(StatusHandler handler)
      Registers the handler of the status change events.
      Parameters:
      handler - the status handler
    • waitEvent

      public ActionEvent waitEvent()
      Waits for an action event.
      Returns:
      the event that has arrived.
    • drawBlock

      public void drawBlock(Block block)
      Draws a single block.
      Parameters:
      block - the block to be drawn
    • drawBlocks

      public void drawBlocks(Block[] blocks)
      Draws an array of blocks.
      Parameters:
      blocks - the blocks to be drawn
    • drawBlocks

      public void drawBlocks(Collection<Block> blocks)
      Draws a collection of blocks.
      Parameters:
      blocks - the blocks to be drawn
    • setLevel

      public void setLevel(int level)
      Sets the level of the game to be displayed.
      Parameters:
      level - the level to be set
    • setScore

      public void setScore(int score)
      Sets the score of the game to be displayed.
      Parameters:
      score - the score to be set
    • setHighScore

      public void setHighScore(int highScore)
      Sets the high score of the game to be displayed.
      Parameters:
      highScore - the high score to be set
    • setStatus

      public void setStatus(Status status)
      Sets the status of the game to be displayed.
      Parameters:
      status - the status to be set
    • clear

      public void clear()
      Clears the graphical user interface.