Exemplo n.º 1
0
 private void installNewPiece() {
   next_piece_canvas.clear();
   cur_piece = next_piece;
   cur_piece.setPosition(3, -4);
   if (cur_piece.canPaste()) {
     next_piece = randomPiece();
     next_piece.setPosition(0, 0);
     next_piece.paste(next_piece_grid);
     next_piece_canvas.repaint();
   } else gameOver();
 }
Exemplo n.º 2
0
  private void removeFullRows() {
    int n_full = countFullRows();
    score_label.addValue((int) (10 * Math.pow(2, n_full) - 10));
    if (n_full == 0) return;

    sounds.playDestroyRows(n_full);

    if (num_rows_deleted / DELETED_ROWS_PER_LEVEL
        != (num_rows_deleted + n_full) / DELETED_ROWS_PER_LEVEL) {
      timer.faster();
      level_label.addValue(n_full / DELETED_ROWS_PER_LEVEL + 1);
      level_label.repaint();
    }

    rows_deleted_label.addValue(n_full);
    num_rows_deleted += n_full;

    for (int i = ROWS - 1; i >= 0; i--) while (rowIsFull(i)) removeRow(i);

    game_grid.repaint();
  }