Class Tetris.Shape
java.lang.Object
uno.anahata.asi.swing.games.Tetris.Shape
- Enclosing class:
Tetris
Represents the layout and operations of a single Tetris block geometry.
- Author:
- anahata
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final int[][]The relative coordinates grid of the four child nodes.private static final int[][][]Global constant mapping ordinal types to physical coordinate patterns.private Tetris.TetrominoesThe category of Tetrominoes shape this instance represents. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetColor()Translates active tetromino types to high-salience design colors.getShape()Accessor for the underlying tetromino category.intminY()Calculates the lowest Y coordinate among all active segment blocks.Performs a left-hand 90-degree vector rotation on the shape block coordinates.voidRandomly assigns a tetromino shape excluding NoShape.voidsetShape(Tetris.Tetrominoes shape) Sets the geometric shape and initializes relative coordinate offsets from coordsTable.intx(int index) Retrieves the relative X coordinate offset for the child segment at the specified index.inty(int index) Retrieves the relative Y coordinate offset for the child segment at the specified index.
-
Field Details
-
pieceShape
The category of Tetrominoes shape this instance represents. -
coords
private final int[][] coordsThe relative coordinates grid of the four child nodes. -
coordsTable
private static final int[][][] coordsTableGlobal constant mapping ordinal types to physical coordinate patterns.
-
-
Constructor Details
-
Shape
public Shape()Constructs a new blank shape initialized to NoShape.
-
-
Method Details
-
setShape
Sets the geometric shape and initializes relative coordinate offsets from coordsTable.- Parameters:
shape- The Tetrominoes category of the shape.
-
setRandomShape
public void setRandomShape()Randomly assigns a tetromino shape excluding NoShape. -
getColor
Translates active tetromino types to high-salience design colors.- Returns:
- The design color of this block.
-
x
public int x(int index) Retrieves the relative X coordinate offset for the child segment at the specified index.- Parameters:
index- The 0-based index of the child block.- Returns:
- relative grid X coordinate offset.
-
y
public int y(int index) Retrieves the relative Y coordinate offset for the child segment at the specified index.- Parameters:
index- The 0-based index of the child block.- Returns:
- relative grid Y coordinate offset.
-
getShape
Accessor for the underlying tetromino category.- Returns:
- The active Tetrominoes ordinal value.
-
minY
public int minY()Calculates the lowest Y coordinate among all active segment blocks.- Returns:
- the minimum Y offset.
-
rotateLeft
Performs a left-hand 90-degree vector rotation on the shape block coordinates.- Returns:
- a new rotated Shape instance.
-

