Esempio n. 1
0
 private void startGame() {
   timer.setDelay(INITIAL_DELAY);
   timer.setPaused(false);
   start_newgame_butt.setLabel("Start New Game");
   pause_resume_butt.setEnabled(true);
   pause_resume_butt.setLabel("Pause");
   pause_resume_butt.validate();
   sounds.playSoundtrack();
 }
Esempio n. 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();
 }
Esempio n. 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();
  }
Esempio n. 4
0
 private void resumeGame() {
   timer.setPaused(false);
   pause_resume_butt.setLabel("Pause");
   sounds.playSoundtrack();
 }
Esempio n. 5
0
 private void pauseGame() {
   timer.setPaused(true);
   pause_resume_butt.setLabel("Resume");
   sounds.stopSoundtrack();
 }