Esempio n. 1
0
    public void mPressed(float mx, float my) {

      if (nextButton.isClicked(mx, my) && isWordCorrect) {
        checkButton.enabled = true;

        wordIndex = wordIndex + 1;
        if (wordIndex >= 10) {
          if (!level1.isComplete()) {
            level1.complete = true;
          } else if (!level2.isComplete()) {
            level2.complete = true;
          } else if (!level3.isComplete()) {
            level3.complete = true;
          }
          wordIndex = 0;
        }
        isWordCorrect = false;
        tfs.setUserWord("");
      } else if (checkButton.isClicked(mx, my) && checkButton.enabled) {
        if (tfs.getTesterWord().equals(tfs.getUserWord())) {
          print("Correct\n");
          checkButton.enabled = false;
          isWordCorrect = true;
          score.incrementScore();
        } else {
          print("Wrong\n");
          if (score.getScore() > 0) {
            score.decrementScore();
          }
        }
      }

      if (startOver.isClicked(mx, my) && level2.isComplete()) {
        quitPressed = true;
      }

      if (quit.isClicked(mx, my)) {
        quit.col = c.gray;
        quitPressed = true;
      }

      if (!level1.isComplete()) {
        if (!level1.didStart()) {
          level1.mPressed(mx, my);
          if (level1.didStart()) {
            checkButton.enabled = true;
          }
        }
      } else if (!level2.isComplete()) {
        if (!level2.didStart()) {
          level2.mPressed(mx, my);
        }
      } else if (!level3.isComplete()) {
        if (!level3.didStart()) {
          level3.mPressed(mx, my);
        }
      }

      tfs.mPressed(mx, my);
    }
Esempio n. 2
0
    public void removeLastLetter() {
      String newWord = tfs.getUserWord();

      if (newWord != null && newWord.length() > 0) {
        newWord = newWord.substring(0, newWord.length() - 1);
        tfs.setUserWord(newWord);
      }
    }
Esempio n. 3
0
    public void enterPressed() {

      if (tfs.getTesterWord().equals(tfs.getUserWord())) {
        score.incrementScore();
        tfs.setUserWord("");

        wordIndex = wordIndex + 1;
        if (wordIndex >= 10) {
          if (!level1.isComplete()) {
            level1.complete = true;
          } else if (!level2.isComplete()) {
            level2.complete = true;
          } else if (!level3.isComplete()) {
            level3.complete = true;
          }
          wordIndex = 0;
        }
      } else {
        if (score.getScore() > 0) {
          score.decrementScore();
        }
      }
    }
Esempio n. 4
0
 public void appendUserWord(String letter) {
   String newWord = tfs.getUserWord() + letter;
   tfs.setUserWord(newWord);
 }