Package tetris.model

Class Figure

java.lang.Object
tetris.model.Figure
Direct Known Subclasses:
IFigure, JFigure, LFigure, OFigure, SFigure, TFigure, ZFigure

public abstract class Figure extends Object
The class Figure implements a figure of the Tetris game.
Version:
2.1
Author:
Stephan Fischli
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final Block[]
    The blocks of the figure.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the blocks of the figure.
    void
    rotate(int d)
    Rotates the figure in the specified direction.
    void
    shift(int dx, int dy)
    Shifts the figure in the specified direction.

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • blocks

      protected final Block[] blocks
      The blocks of the figure.
  • Constructor Details

    • Figure

      public Figure()
  • Method Details

    • getBlocks

      public Block[] getBlocks()
      Gets the blocks of the figure.
      Returns:
      the blocks of the figure
    • shift

      public void shift(int dx, int dy)
      Shifts the figure in the specified direction.
      Parameters:
      dx - the x coordinate of the direction
      dy - the y coordinate of the direction
    • rotate

      public void rotate(int d)
      Rotates the figure in the specified direction.
      Parameters:
      d - the direction of rotation (+1 right, -1 left)