Beispiel #1
0
 private void newGame() {
   game_grid.clear();
   installNewPiece();
   num_rows_deleted = 0;
   rows_deleted_label.setText("0");
   level_label.setText("1");
   score_label.setText("0");
   startGame();
 }
Beispiel #2
0
 private void gameOver() {
   System.out.println("Game Over!");
   timer.setPaused(true);
   pause_resume_butt.setEnabled(false);
   int score = Integer.parseInt(score_label.getText());
   int high_score =
       high_score_label.getText().length() > 0 ? Integer.parseInt(high_score_label.getText()) : 0;
   if (score > high_score) high_score_label.setText("" + score);
   sounds.playGameOverSound();
 }
Beispiel #3
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();
  }