protected void clearLines() {

    int linesCleared = 0;

    for (int y = 0; y < getHeight(); y++) {
      boolean lineCleared = true;
      // find lines to clear
      for (int x = 0; x < getWidth(); x++) {
        if (playfield[x + y * getWidth()] == null)
          lineCleared = false;
      }

      // clear line
      if (lineCleared) {
        linesCleared++;
        clearingRows[y] = true;

        for (int x = 0; x < getWidth(); x++) {
          playfield[x + y * getWidth()].piece.erased = true;
          playfield[x + y * getWidth()] = null;
        }
      }
    }
    // Scoring: 40 * (n + 1) 100 * (n + 1) 300 * (n + 1) 1200 * (n + 1)
    int multiplier;
    switch (linesCleared) {
    case 1:
      multiplier = 40;
      break;
    case 2:
      multiplier = 100;
      break;
    case 3:
      multiplier = 300;
      break;
    case 4:
      multiplier = 1200;
      break;
    default:
      multiplier = 0;
    }
    this.lines += linesCleared;
    this.score += multiplier * (getLevel() + 1);
  }