Exemplo n.º 1
0
 /**
  * Check if there are any Blocks in the specified cell
  *
  * @param x the X coord
  * @param y the Y coord
  * @return wheather or not any Blocks are in that Cell
  */
 public boolean isInCell(int x, int y) {
   if (x == -1 && y == -1) return false;
   for (TetrisBlock B : shapeBlocks) {
     if ((x == -1 || B.getInt(0) == x) && (y == -1 || B.getInt(1) == y)) return true;
   }
   return false;
 }
Exemplo n.º 2
0
 /** Get the top most block in this shape */
 public TetrisBlock getTopMostBlock() {
   TetrisBlock T = null;
   for (TetrisBlock B : shapeBlocks) {
     if (T == null || T.getInt(1) > B.getInt(1)) T = B;
   }
   return T;
 }
Exemplo n.º 3
0
 /**
  * Count all the Blocks that are in the given row
  *
  * @param y the given row
  * @return the number of hits
  */
 public int countCellsInRow(int y) {
   int count = 0;
   for (TetrisBlock B : shapeBlocks) {
     if ((B.getInt(1) == y)) ++count;
   }
   return count;
 }
Exemplo n.º 4
0
 /**
  * Return the lowest block in a specific column
  *
  * @param x The given column to search in
  * @return The lowest block in that column
  */
 public TetrisBlock getBottomMostBlock(int x) {
   TetrisBlock T = null;
   for (TetrisBlock B : shapeBlocks) {
     if (B.getInt(0) == x && (T == null || T.getInt(1) < B.getInt(1))) T = B;
   }
   return T;
 }
Exemplo n.º 5
0
 /** Get the right most block in this shape */
 public TetrisBlock getRightMostBlock() {
   TetrisBlock T = null;
   for (TetrisBlock B : shapeBlocks) {
     if (T == null || T.getInt(0) < B.getInt(0)) T = B;
   }
   return T;
 }
Exemplo n.º 6
0
 /**
  * Get the left most block in this shape for the given row
  *
  * @param y The specified row to look at
  */
 public TetrisBlock getLeftMostBlock(int y) {
   TetrisBlock T = null;
   for (TetrisBlock B : shapeBlocks) {
     if (B.getInt(1) == y && (T == null || T.getInt(0) > B.getInt(0))) T = B;
   }
   return T;
 }
Exemplo n.º 7
0
 /**
  * Move the shape on the X axes
  *
  * @param amX The amount to move on the X axes
  */
 public void moveShapeX(int amX) {
   for (TetrisBlock B : shapeBlocks) {
     B.setInt(0, B.getInt(0) + amX);
   }
 }
Exemplo n.º 8
0
 /**
  * Move a specific block in this shape
  *
  * @param Block the block to move
  * @param amX The amount to move on the X axes
  * @param amY The amount to move on the Y axes
  */
 protected void moveBlock(TetrisBlock block, int amX, int amY) {
   block.setInt(0, block.getInt(0) + amX);
   block.setInt(1, block.getInt(1) + amY);
 }
Exemplo n.º 9
0
 public TetrisBlock getBlock(int x, int y) {
   for (TetrisBlock B : shapeBlocks) {
     if (B.getInt(0) == x && B.getInt(1) == y) return B;
   }
   return null;
 }
Exemplo n.º 10
0
 /** Set this shape at the top of the grid */
 public void setShapeTopGrid() {
   int YDist = getTopMostBlock().getInt(1);
   for (TetrisBlock B : shapeBlocks) {
     B.setInt(1, B.getInt(1) - YDist);
   }
 }
Exemplo n.º 11
0
 /**
  * Move the shape on the Y axes
  *
  * @param amY The amount ot move on the Y axes
  */
 public void moveShapeY(int amY) {
   for (TetrisBlock B : shapeBlocks) {
     B.setInt(1, B.getInt(1) + amY);
   }
 }