Пример #1
0
  public void startGame() {
    hasStarted = true;

    // reset grid
    gridManager.clearGrid();

    // generate random piece
    currentPiece = pieceGenerator.getRandomPiece();

    // set pieceController to currentPiece
    pieceController.setCurrentTetrisPiece(currentPiece);

    pieceController.placeCurrentTetrisPieceAt(2, 2);

    // other stuff like clearing levels and score.
  }
Пример #2
0
  public boolean[][] startGameLoop() {
    if (!hasStarted()) startGame();
    else {
      // piece either collided with another piece or has reached bottom
      if (hasCollision()) {
        // some check to see if there are any filled rows.
        // then perform a collapse on the grid

        // do next iteration.
        performNextIteration();
      } else {
        // retrieve action.
        Actions userAction = getCurrentAction();

        // perform the action
        performAction(userAction);
      }
    }

    return gridManager.getGridInfo();
  }
Пример #3
0
 private boolean hasCollided() {
   return gridManager.hasCollidedBelow(currentPiece.getBlocks());
 }
Пример #4
0
 // get copy of data of grid for reference.
 public boolean[][] getPieceData() {
   return gridManager.getGridInfo();
 }