softDrop method

void softDrop()

Moves the piece down one row for 1 point. If the piece is already resting on the stack it locks immediately.

Implementation

void softDrop() {
  final piece = _activePiece;
  if (piece == null) return;
  _record('softDrop');
  if (_collision.canMove(piece, _state.board, 1, 0)) {
    _state = _state.copyWith(
      activePiece: _shifted(piece, 1, 0),
      scoreState: _scoring.onSoftDrop(_state.scoreState, 1),
    );
    _lastMoveWasRotation = false;
    _emit(
      TetrisEvent(TetrisEventType.softDropped, piece: piece.type, cells: 1),
    );
    _onPieceMoved();
    notifyListeners();
  } else {
    _lockPiece();
  }
}