Class PieceModel


  • public class PieceModel
    extends java.lang.Object
    • Field Detail

      • COLOR_AQUA

        public static final java.awt.Color COLOR_AQUA
      • COLOR_GREEN

        public static final java.awt.Color COLOR_GREEN
      • COLOR_RED

        public static final java.awt.Color COLOR_RED
      • COLOR_PURPLE

        public static final java.awt.Color COLOR_PURPLE
      • COLOR_ORANGE

        public static final java.awt.Color COLOR_ORANGE
      • COLOR_BLUE

        public static final java.awt.Color COLOR_BLUE
      • COLOR_YELLOW

        public static final java.awt.Color COLOR_YELLOW
      • COLOR_OLIVE

        public static final java.awt.Color COLOR_OLIVE
      • COLOR_ORANGERED

        public static final java.awt.Color COLOR_ORANGERED
      • COLOR_CYAN

        public static final java.awt.Color COLOR_CYAN
      • COLOR_DARKPURPLE

        public static final java.awt.Color COLOR_DARKPURPLE
      • COLOR_GOLD

        public static final java.awt.Color COLOR_GOLD
      • COLOR_DARKGOLD

        public static final java.awt.Color COLOR_DARKGOLD
      • COLOR_DARKPINK

        public static final java.awt.Color COLOR_DARKPINK
      • COLOR_LIGHTPINK

        public static final java.awt.Color COLOR_LIGHTPINK
      • COLOR_GRAY

        public static final java.awt.Color COLOR_GRAY
      • COLOR_WHITE

        public static final java.awt.Color COLOR_WHITE
      • x

        int x
      • y

        int y
      • spawnPoint

        java.awt.Point spawnPoint
      • name

        java.lang.String name
      • ignoreCollisionWithFalling

        public boolean ignoreCollisionWithFalling
      • PiecesCustoms

        static PieceModel[] PiecesCustoms
    • Constructor Detail

      • PieceModel

        public PieceModel​(BlockModel[][] childs,
                          java.awt.Point spawnPoint,
                          java.lang.String name)
    • Method Detail

      • changeColor

        public void changeColor​(java.awt.Color color)
        Change the color of piece
        Parameters:
        color - the color to change to
      • rotateClockWise

        private static BlockModel[][] rotateClockWise​(BlockModel[][] matrix,
                                                      java.lang.String name)
        Rotate a given array of blocks
        Parameters:
        matrix - the arrays
        name - Name of the piece (used for rotation)
        Returns:
        the array rotated clockwise
      • rotateConterClockWise

        private static BlockModel[][] rotateConterClockWise​(BlockModel[][] matrix,
                                                            java.lang.String name)
        Rotate a given array of blocks
        Parameters:
        matrix - the arrays
        name - Name of the piece (used for rotation)
        Returns:
        the array rotated counter clockwise
      • rotateModel

        void rotateModel​(int direction,
                         java.lang.String name)
        Rotate the piece based on the given direction
        Parameters:
        direction - the direction
        name - Name of the piece (used for rotation)
      • clone

        protected PieceModel clone()
        Overrides:
        clone in class java.lang.Object
      • getPieceHeight

        int getPieceHeight()
        Calculate a piece height (was used for the drop preview)
        Returns:
        the piece height
      • getBlockCount

        int getBlockCount()
        Calculate a number of block in a piece
        Returns:
        the block count
      • getPieces

        public static PieceModel[] getPieces()
        Get all the pieces depending if the legacy option is used
        Returns:
        an array containing all the pieces