Advertisement
Guest User

Untitled

a guest
Apr 20th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function CheckId(buttonId) { //Check if you choose correct button
  2.  
  3. if (buttonId == MyrndBtn) {  // if you do, your score is increased, new problem is set, new "left points" is set and new time limit
  4.   Score++;
  5.   console.log("correct");
  6.   SetButtons();
  7.   setText("ScoreCounter", Score);
  8.   clearTimeout(timeout);
  9.   ScoreCountLeft = WantedScore - Score;
  10.   setText("ScoreCounterLeft",ScoreCountLeft);
  11.  
  12.  
  13.   if (Score == WantedScore) { // if youo reach your wanted score, you win, sets random victory gif
  14.   NewGame();
  15.   setImageURL("wingif", wingifs[randomNumber(0,4)]);
  16.   showElement(winarray[0]);
  17.   showElement(winarray[1]);
  18.   showElement(winarray[2]);
  19. }
  20. else{ //If not, sets new timelimit, and in case you do not make it in limit, you lose, shows random lose gif
  21.  timeout = setTimeout(function() {
  22.   console.log("it is over");
  23.   setScreen("screen5");
  24.   NewGame();
  25.   setImageURL("losegif", losegifs[randomNumber(0,2)]);
  26.   showElement(losearray[0]);
  27.   showElement(losearray[1]);
  28.   showElement(losearray[2]);
  29. }, MyTimeout);}
  30.  
  31.  
  32. } else { // if you choose the wring answer, your score decreases by 1, the incorrect button hides and new score displays
  33.   Score--;
  34.   console.log("incorrect");
  35.   hideElement(buttonId);
  36.   console.log(MyrndBtn);
  37.   setText("ScoreCounter", Score);
  38.   ScoreCountLeft = WantedScore - Score;
  39. setText("ScoreCounterLeft",ScoreCountLeft);
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement