Interface GameControls

All Known Subinterfaces:
PropertyChangeEnabledGameControls
All Known Implementing Classes:
TetrisGame

public interface GameControls
The controls for a Tetris game. A Tetris game consists of the following constructs:
  • A game state as defined by the GameState enum.
  • A game "board" made up of width (w) by height (h) blocks.
    • The data class Point is used to represent a location on the board.
    • The "bottom" row of the board is represented by y = 0
      • Positive y moves "up" the board
    • The "right" column of the board is represented by x = 0
      • Positive x moves "right" across the board
  • A current movable piece that the user may manipulate.
    • The data class IndividualPiece is used to represent the current movable piece.
  • A set of frozen blocks that represent all Tetris Block objects that have frozen into place.
Version:
Autumn 25
Author:
Charles Bryan
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static enum 
    The different types of blocks that can be stored in a Board's grid.
    static final record 
    Data class that represents all Tetris Block objects that have frozen into place.
    static enum 
    Specifies a game state for Tetris.
    static final record 
    Data class that represents a single Tetris tetromino in a location on the Tetris board.
    static final record 
    Data class that represents a "point" on the Tetris game board.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Try to move the movable piece down.
    void
    Drop the movable piece until it is set.
    void
    Places the game in GameState.OVER.
    void
    Try to move the movable piece left.
    void
    Places the game in GameState.NEW followed by placing the game into GameState.RUNNING.
    void
    Places the game into GameState.PAUSED.
    void
    Try to move the movable piece right.
    void
    Try to rotate the movable piece in the counter-clockwise direction.
    void
    Try to rotate the movable piece in the clockwise direction.
    void
    Advances the game by one 'step'.
    void
    Toggles the game into either GameState.RUNNING or GameState.PAUSED.
    void
    Places the game into GameState.RUNNING.
  • Method Details

    • newGame

      void newGame()
      Places the game in GameState.NEW followed by placing the game into GameState.RUNNING. This method must be called before the first game and before each new game. No restriction on the current GameState is enforced.
    • endGame

      void endGame()
      Places the game in GameState.OVER. The game must be in GameState.PAUSED or GameState.RUNNING for this action to have an effect.
    • step

      void step()
      Advances the game by one 'step'. The game must be in GameState.RUNNING for this action to have an effect.
      This action could include:
      • moving the movable piece down 1 line
      • freezing the movable piece if appropriate (which may end the game placing it into GameState.OVER)
      • clearing full lines as needed
    • down

      void down()
      Try to move the movable piece down. The game must be in GameState.RUNNING for this action to have an effect.
      This action could include:
      • freezing the movable piece if appropriate (which may end the game placing it into GameState.OVER)
      • clearing full lines as needed
    • left

      void left()
      Try to move the movable piece left. The game must be in GameState.RUNNING for this action to have an effect.
    • right

      void right()
      Try to move the movable piece right. The game must be in GameState.RUNNING for this action to have an effect.
    • rotateCW

      void rotateCW()
      Try to rotate the movable piece in the clockwise direction. The game must be in GameState.RUNNING for this action to have an effect.
    • rotateCCW

      void rotateCCW()
      Try to rotate the movable piece in the counter-clockwise direction. The game must be in GameState.RUNNING for this action to have an effect.
    • drop

      void drop()
      Drop the movable piece until it is set. The game must be in GameState.RUNNING for this action to have an effect. This action will include:
      • freezing the movable piece (which may end the game placing it into GameState.OVER)
      • clearing full lines as needed
    • pause

      void pause()
      Places the game into GameState.PAUSED. The game must be in GameState.RUNNING for this action to have an effect.
    • unPause

      void unPause()
      Places the game into GameState.RUNNING. The game must be in GameState.PAUSED for this action to have an effect.
    • togglePause

      void togglePause()
      Toggles the game into either GameState.RUNNING or GameState.PAUSED. More formally, if the game is in GameState.PAUSED this action places the game into GameState.RUNNING and if the game is in GameState.RUNNING, this action places the game in GameState.PAUSED. The game must be in GameState.PAUSED or GameState.RUNNING for this action to have an effect.